Deploy Go Auth Service
Deploy and Host Go Auth Service with Railway
go-auth-service
Just deployed
Redis
Just deployed
/data
Just deployed
/var/lib/postgresql/data
Deploy and Host Go Auth Service on Railway
Go Auth Service is a production-ready authentication microservice built with Go that provides JWT-based authentication with OAuth 2.0 support for Google, GitHub, and Microsoft. It handles user registration, login, session management, and role-based access control for modern SaaS applications.
About Hosting Go Auth Service
Hosting Go Auth Service on Railway provides a complete authentication infrastructure for your applications. The service requires PostgreSQL for user data storage and optionally Redis for session caching. Railway's automatic deployments from GitHub, built-in PostgreSQL and Redis services, and environment variable management make it straightforward to deploy and scale. The service exposes REST APIs for user authentication, OAuth flows, and service-to-service user queries, making it ideal as a standalone auth microservice that integrates with your existing backend services (Python, Node.js, etc.).
Common Use Cases
- SaaS Authentication Backend - Centralized authentication service for web applications with user registration, login, and profile management
- Microservices Architecture - Standalone auth service that provides JWT token generation and validation for multiple backend services
- Multi-Provider OAuth Integration - Single authentication endpoint supporting Google, GitHub, and Microsoft social logins with automatic user account creation
Dependencies for Go Auth Service Hosting
- PostgreSQL Database - Required for storing user accounts, sessions, OAuth connections, and refresh tokens
- Redis - Optional but recommended for caching and session management to improve performance
Deployment Dependencies
- PostgreSQL on Railway - Managed PostgreSQL database service
- Redis on Railway - Managed Redis cache service
- Go 1.24+ - Programming language runtime
- OAuth Provider Credentials - Google, GitHub, or Microsoft OAuth app credentials (optional)
Implementation Details
Environment Variables Setup:
# Required
DATABASE_URL=postgresql://user:password@host:port/dbname?sslmode=require
REDIS_URL=redis://:password@host:port/0
JWT_SECRET=your-super-secret-jwt-key-min-32-chars
CORS_ORIGINS=https://your-frontend-domain.com
AUTH_FRONTEND_URL=https://your-frontend-domain.com
# OAuth (Optional)
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
GOOGLE_REDIRECT_URL=https://your-auth-api.railway.app/api/v1/auth/oauth/google/callback
Integration Example (Python Backend):
import requests
# Validate user token from your Python backend
response = requests.get(
"https://your-auth-service.railway.app/api/v1/users/123e4567-e89b-12d3-a456-426614174000",
headers={"Authorization": f"Bearer {access_token}"}
)
user = response.json()
Client Authentication Flow:
// Frontend login
const response = await fetch('https://your-auth-service.railway.app/api/v1/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: 'password' })
});
const { access_token, refresh_token } = await response.json();
Why Deploy Go Auth Service on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Go Auth Service on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
go-auth-service
rubenszinho/go-auth-serviceENV
Values must be 'production' or 'development'
CORS_ORIGINS
CORS must not be * on production mode
AUTH_FRONTEND_URL
e.g. "https://auth-client.com"
Redis
redis:8.2.1
