---
title: "Deploy Go Auth Service"
description: "Deploy and Host Go Auth Service with Railway"
category: "Authentication"
url: https://railway.com/deploy/go-auth-service
---

# Deploy Go Auth Service

Deploy and Host Go Auth Service with Railway

**[Deploy Go Auth Service on Railway](https://railway.com/template/go-auth-service)**

- **Creator:** Rubrion
- **Category:** Authentication

## Template content

### go-auth-service https://devicons.railway.app/go

- **Source:** rubenszinho/go-auth-service

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2.1
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:17

## Documentation

# 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](https://docs.railway.app/databases/postgresql) - Managed PostgreSQL database service
- [Redis on Railway](https://docs.railway.app/databases/redis) - Managed Redis cache service
- [Go 1.24+](https://go.dev/) - Programming language runtime
- [OAuth Provider Credentials](https://console.cloud.google.com/apis/credentials) - Google, GitHub, or Microsoft OAuth app credentials (optional)

### Implementation Details

**Environment Variables Setup:**

```bash
# 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):**

```python
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:**

```javascript
// 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: 'user@example.com', 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.

## Similar templates

- [Keycloak](https://railway.com/deploy/mSwigX) — Keycloak template with keywind theme + apple and discord providers
- [lua-protector](https://railway.com/deploy/lua-protector) — Test deployed my project first
- [bknd](https://railway.com/deploy/p4nTYL) — Feature-rich yet lightweight backend

Open this page in a browser: https://railway.com/deploy/go-auth-service
