<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mohnasr137</title>
    <description>The latest articles on DEV Community by mohnasr137 (@mohnasr137).</description>
    <link>https://dev.to/mohnasr137</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F877802%2Fa73d43c6-a78d-414d-80bf-194c869546ae.jpg</url>
      <title>DEV Community: mohnasr137</title>
      <link>https://dev.to/mohnasr137</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mohnasr137"/>
    <language>en</language>
    <item>
      <title>Building a Self-Hosted Authentication Gateway with Go and Keycloak</title>
      <dc:creator>mohnasr137</dc:creator>
      <pubDate>Thu, 19 Nov 2026 18:32:50 +0000</pubDate>
      <link>https://dev.to/mohnasr137/building-a-self-hosted-authentication-gateway-with-go-and-keycloak-3cjc</link>
      <guid>https://dev.to/mohnasr137/building-a-self-hosted-authentication-gateway-with-go-and-keycloak-3cjc</guid>
      <description>&lt;p&gt;A lightweight, self-hosted authentication gateway built with Go, Gin, and Keycloak, designed to simplify authentication in microservices architectures.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Why I built short-auth
&lt;/h2&gt;

&lt;p&gt;Authentication is one of those things that can become unnecessarily complicated when building backend systems, especially microservices.&lt;/p&gt;

&lt;p&gt;You have two common options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Managed authentication services&lt;/strong&gt; like Auth0 and Clerk. They're convenient, but costs can grow as your application scales.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-hosted Identity Providers&lt;/strong&gt; like Keycloak. They're powerful and flexible, but integrating them directly into your applications requires dealing with clients, scopes, OAuth2/OIDC flows, token lifecycles, roles, permissions, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Keycloak is an excellent Identity Provider. However, I wanted a simpler way to use its capabilities without having to handle all its configuration and integration details in every project.&lt;/p&gt;

&lt;p&gt;What if we could put a lightweight API layer on top of Keycloak and get a straightforward authentication service that works across multiple backend applications?&lt;/p&gt;

&lt;p&gt;That's the idea behind &lt;strong&gt;short-auth&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ How it works
&lt;/h2&gt;

&lt;p&gt;short-auth combines two main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Go + Gin:&lt;/strong&gt; Provides the authentication API, middleware, and local token verification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keycloak:&lt;/strong&gt; Handles identity management, user authentication, and OAuth2/OIDC flows.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both are packaged into a single Docker image.&lt;/p&gt;

&lt;p&gt;The architecture separates authentication operations from token verification:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Authentication operations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Registration, login, password management, and other identity operations are delegated to Keycloak through its APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Token verification&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of requesting token validation from Keycloak on every incoming request, short-auth verifies JWT signatures locally using cached RSA public keys obtained through JWKS.&lt;/p&gt;

&lt;p&gt;This allows downstream microservices to validate tokens without making an external Identity Provider request for every verification.&lt;/p&gt;

&lt;h2&gt;
  
  
  ✨ Key Features
&lt;/h2&gt;

&lt;p&gt;Here's what short-auth currently provides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔐 &lt;strong&gt;Authentication API:&lt;/strong&gt; Register, Login, Refresh, Logout, Change Password, and Forgot Password.&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Local JWT Verification:&lt;/strong&gt; RSA signature verification using cached JWKS public keys.&lt;/li&gt;
&lt;li&gt;🌐 &lt;strong&gt;Google OAuth2:&lt;/strong&gt; Preconfigured social login integration.&lt;/li&gt;
&lt;li&gt;🛡️ &lt;strong&gt;Role-Based Access Control:&lt;/strong&gt; Authentication middleware and role enforcement.&lt;/li&gt;
&lt;li&gt;🍪 &lt;strong&gt;Secure Cookies:&lt;/strong&gt; HttpOnly, Secure, and SameSite support.&lt;/li&gt;
&lt;li&gt;🚦 &lt;strong&gt;Rate Limiting:&lt;/strong&gt; 64-shard in-memory rate limiter to reduce lock contention under concurrency.&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Refresh Token Rotation:&lt;/strong&gt; Token rotation and revocation.&lt;/li&gt;
&lt;li&gt;🗄️ &lt;strong&gt;Database Support:&lt;/strong&gt; PostgreSQL and MySQL.&lt;/li&gt;
&lt;li&gt;📦 &lt;strong&gt;Single Docker Image:&lt;/strong&gt; Go authentication gateway and Keycloak packaged together.&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Automatic Database Initialization:&lt;/strong&gt; Keycloak provisions its database tables on first startup.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📊 Performance Benchmarks
&lt;/h2&gt;

&lt;p&gt;One of the interesting parts of this project was optimizing local JWT verification.&lt;/p&gt;

&lt;p&gt;I used &lt;strong&gt;Grafana k6 and hey&lt;/strong&gt; to benchmark the verification endpoint under concurrent load.&lt;/p&gt;

&lt;p&gt;Here are the recorded results:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Peak Throughput / Arrival Rate&lt;/td&gt;
&lt;td&gt;10,000 RPS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Verification Latency&lt;/td&gt;
&lt;td&gt;489.5 µs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Total Requests&lt;/td&gt;
&lt;td&gt;439,362&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP Errors&lt;/td&gt;
&lt;td&gt;0.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The tests were performed on both PostgreSQL and MySQL integration setups.&lt;/p&gt;

&lt;p&gt;The benchmark results, execution logs, and tuning notes are available in the repository.&lt;/p&gt;

&lt;p&gt;These numbers represent the tested environment, not a guarantee of identical performance in every deployment.&lt;/p&gt;

&lt;h2&gt;
  
  
  🐳 Getting Started
&lt;/h2&gt;

&lt;p&gt;The easiest way to try short-auth is with Docker Compose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Clone the repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/mohnasr137/short-auth.git

&lt;span class="nb"&gt;cd&lt;/span&gt; short-auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Configure your environment&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cp .env.example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure your database connection and credentials in &lt;code&gt;.env&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Start the service&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Check the health endpoint&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:3000/health
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the first startup, Keycloak initializes its database tables and imports the authentication realm. This may take around 20–40 seconds.&lt;/p&gt;

&lt;p&gt;You can also use the provided integration examples to run short-auth with PostgreSQL or MySQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔌 API Overview
&lt;/h2&gt;

&lt;p&gt;All authentication endpoints are prefixed with &lt;code&gt;/api/auth&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/register&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Register a user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/login&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Authenticate and issue tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/refresh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Refresh tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/logout&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Revoke session&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/verify&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verify access token&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/me&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get authenticated user&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PUT&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/change-password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Change password&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/forgot-password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Request password reset&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/google&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Start Google OAuth2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A ready-to-use Postman collection is also included in the repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔮 What's Next?
&lt;/h2&gt;

&lt;p&gt;short-auth is still evolving.&lt;/p&gt;

&lt;p&gt;My goal is to make it easier for backend developers to integrate self-hosted authentication into their applications without having to build and maintain the entire authentication infrastructure themselves.&lt;/p&gt;

&lt;p&gt;There are still areas I'd like to improve, and feedback from other developers would be extremely valuable.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 I'd Love Your Feedback
&lt;/h2&gt;

&lt;p&gt;I'm particularly interested in hearing your thoughts on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Would you use a dedicated authentication gateway instead of integrating Keycloak directly into each microservice?&lt;/li&gt;
&lt;li&gt;What do you think about packaging Go and Keycloak in a single container?&lt;/li&gt;
&lt;li&gt;Are there architectural or security concerns you'd address differently?&lt;/li&gt;
&lt;li&gt;What features would make a project like this more useful in real-world applications?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're interested in the project, contributions, issues, and suggestions are welcome.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/mohnasr137/short-auth" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/short-auth&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🐳 &lt;strong&gt;Docker Hub:&lt;/strong&gt; &lt;a href="https://hub.docker.com/r/mohnasr137/short-auth" rel="noopener noreferrer"&gt;https://hub.docker.com/r/mohnasr137/short-auth&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Built with Go. Powered by Keycloak. Open Source.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading! 🚀&lt;/p&gt;

</description>
      <category>go</category>
      <category>keycloak</category>
      <category>opensource</category>
      <category>microservices</category>
    </item>
    <item>
      <title>5 Web 3D Experiments I Built with Three.js</title>
      <dc:creator>mohnasr137</dc:creator>
      <pubDate>Sun, 04 Oct 2026 09:58:41 +0000</pubDate>
      <link>https://dev.to/mohnasr137/5-web-3d-experiments-i-built-with-threejs-58b</link>
      <guid>https://dev.to/mohnasr137/5-web-3d-experiments-i-built-with-threejs-58b</guid>
      <description>&lt;p&gt;I recently revisited some of my older Web 3D experiments and pushed them further with improvements, new rendering techniques, and browser previews.&lt;/p&gt;

&lt;p&gt;Here are the projects, from simpler experiments to more advanced rendering work:&lt;/p&gt;

&lt;p&gt;🧊 Cube 3D&lt;/p&gt;

&lt;p&gt;An interactive 3D geometry showcase with lighting and orbit controls.&lt;/p&gt;

&lt;p&gt;Preview: &lt;a href="https://cube-3d.onrender.com" rel="noopener noreferrer"&gt;https://cube-3d.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/mohnasr137/cube-3d" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/cube-3d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🚀 Tube 3D&lt;/p&gt;

&lt;p&gt;A sci-fi neon tunnel featuring spline-based camera movement and UnrealBloom post-processing.&lt;/p&gt;

&lt;p&gt;Preview: &lt;a href="https://tube-3d.onrender.com" rel="noopener noreferrer"&gt;https://tube-3d.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/mohnasr137/tube-3d" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/tube-3d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🌍 Earth 3D&lt;/p&gt;

&lt;p&gt;A real-time 3D Earth with textures, clouds, city lights, procedural stars, and a custom GLSL atmospheric shader.&lt;/p&gt;

&lt;p&gt;Preview: &lt;a href="https://earth-3d.onrender.com" rel="noopener noreferrer"&gt;https://earth-3d.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/mohnasr137/earth-3d" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/earth-3d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🌌 Gravity 3D&lt;/p&gt;

&lt;p&gt;A real-time physics simulation using Rapier 3D, where hundreds of bodies interact through gravity and collisions.&lt;/p&gt;

&lt;p&gt;Preview: &lt;a href="https://gravity-3d.onrender.com" rel="noopener noreferrer"&gt;https://gravity-3d.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/mohnasr137/gravity-3d" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/gravity-3d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔷 Icosahedron 3D&lt;/p&gt;

&lt;p&gt;The project I explored the most from a rendering perspective, using InstancedMesh, offscreen rendering, FBOs, and GLSL shaders.&lt;/p&gt;

&lt;p&gt;Preview: &lt;a href="https://icosahedron-3d.onrender.com" rel="noopener noreferrer"&gt;https://icosahedron-3d.onrender.com&lt;/a&gt;&lt;br&gt;
Code: &lt;a href="https://github.com/mohnasr137/icosahedron-3d" rel="noopener noreferrer"&gt;https://github.com/mohnasr137/icosahedron-3d&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These projects started as experiments, but revisiting them gave me a better understanding of WebGL rendering, shaders, post-processing, and real-time graphics.&lt;/p&gt;

&lt;p&gt;If you're interested in Three.js or WebGL, I'd love to hear which project you find the most interesting.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>github</category>
      <category>frontend</category>
      <category>design</category>
    </item>
  </channel>
</rss>
