The Tokye Auth Server is a robust and lightweight authentication server designed for the Tokye project. It provides a seamless and secure user authentication experience, leveraging modern standards such as passkeys and passwordless authentication.
This service utilizes JSON Web Tokens (JWT) to ensure secure and easy-to-verify authentication, making it compatible across various backend systems.
With a focus on simplicity, the Tokye Auth Server offers a user-friendly interface for authentication while maintaining high security standards. By integrating passwordless authentication, it eliminates the need for traditional passwords, enhancing both security and user experience.
- Passwordless Authentication: Simplifies user interaction by replacing traditional passwords with passkeys.
- JWT-based Authentication: Generates and verifies JSON Web Tokens, ensuring security and compatibility with various backends.
- Scalable and Efficient: Built using modern, lightweight technologies designed for performance and scalability.
- WebAuthn Integration: Uses simplewebauthn to support WebAuthn standards for secure and seamless user authentication.
The Tokye Auth Server is powered by a modern and efficient tech stack:
- PostgreSQL: A reliable and powerful relational database for storing user data and authentication metadata.
- Redis: High-performance in-memory data storage, used for caching and session management.
- Go: A fast, efficient, and scalable programming language that powers the core of the server.
- FileBased: A file-based router for the Echo web framework, making it easy to manage and modify large routing configurations
- JWT: JSON Web Tokens for easy-to-verify, stateless authentication across backend systems.
- simplewebauthn: A library for implementing WebAuthn standards, enabling strong passwordless authentication.
To get started with the Tokye Auth Server, follow the steps below:
-
Clone the repository:
git clone https://github.com/BenDerFarmer/tokye-auth-server.git cd tokye-auth-server -
Configure your environment:
- Set up your PostgreSQL and Redis instances.
- Update the configuration file with your database and Redis connection details.
-
Build and run the server:
go build ./tokye-auth-server
-
Integrate it with the Tokye Client or your existing applications.
With the increasing need for secure and user-friendly authentication solutions, Tokye Auth Server bridges the gap by offering:
- Simplified authentication with passwordless login.
- High security through the use of WebAuthn and modern cryptographic standards.
- A developer-friendly approach with well-documented APIs and easy integration options.
Whether you're building a new project or enhancing an existing one, the Tokye Auth Server makes secure authentication effortless.
The Tokye Auth Server relies on several environment variables for configuration. These variables allow you to customize the server's behavior and integrate it with your infrastructure. Below is a breakdown of each environment variable and its purpose:
-
REFRESH_TOKEN_SECRET(required):
A secret key used to sign and verify refresh tokens. Ensure this is a strong, randomly generated string to maintain token security. -
SQL_DSN(required):
The Data Source Name (DSN) for connecting to your PostgreSQL database. Format example:host=127.0.0.1 user=gorm password=mysecretpassword dbname=gorm port=5432 sslmode=disable TimeZone=Europe/Berlin.
These variables configure the SMTP server for sending emails, such as for account verification or passwordless login links.
-
SMTP_DOMAIN(required):
The domain name of your SMTP service provider. -
SMTP_PORT(default:465):
The port used to connect to the SMTP server. Typically465for SSL or587for STARTTLS. -
SMTP_USERNAME(required):
The username or email address used to authenticate with the SMTP server. -
SMTP_PASSWORD(required):
The password for your SMTP account. -
SMTP_FROM_MAIL(default:SMTP_USERNAME):
The email address used in the "From" field of outgoing emails. If not provided, it defaults to the SMTP username.
These variables configure the Redis instance for caching and session management.
-
REDIS_ADDRESS(default:localhost:6379):
The address and port of your Redis instance. -
REDIS_USERNAME(optional):
The username for authenticating with Redis (if applicable). -
REDIS_PASSWORD(optional):
The password for authenticating with Redis. -
REDIS_DATABASE(default:0):
The Redis database index to use.
These variables configure settings for passkey-based authentication.
-
PASSKEY_DISPLAYNAME(default:Auth):
The display name of the relying party (RP), shown to users during passkey authentication. -
PASSKEY_RPID(required):
The Relying Party Identifier (RPID) for passkey operations. Typically, this is your application's domain (e.g.,example.com). -
PASSKEY_ORIGINS(default: empty):
A semicolon-separated list of allowed origins for passkey operations (e.g.,https://example.com;https://app.example.com).
CORS_ORIGINS(default: empty):
A semicolon-separated list of allowed origins for Cross-Origin Resource Sharing (CORS). Example:http://localhost:3000;https://example.com.
-
DEBUG_MODE(default:false):
Enables debug logging when set totrue. Useful during development to identify issues. -
PORT(default:3000):
The port on which the server will run. Example:8080for production.
REFRESH_TOKEN_SECRET=vFNjHjFccr%fUN6A%Uwb4TM5UA!mSD^NuW3*nEWk*EM^WQjK9K
SQL_DSN="host=127.0.0.1 user=gorm password=mysecretpassword dbname=gorm port=5432 sslmode=disable TimeZone=Europe/Berlin"
SMTP_DOMAIN=smtp.example.com
SMTP_PORT=465
SMTP_USERNAME=auth@example.com
SMTP_PASSWORD=securepassword
SMTP_FROM_MAIL=auth@example.com
REDIS_ADDRESS=localhost:6379
REDIS_USERNAME=
REDIS_PASSWORD=
REDIS_DATABASE=0
PASSKEY_DISPLAYNAME=Tokye Auth
PASSKEY_RPID=example.com
PASSKEY_ORIGINS=https://example.com;https://auth.example.com
CORS_ORIGINS=http://localhost:3000;https://example.com
DEBUG_MODE=true
PORT=3000