AuthLite is a lightweight OAuth2 provider implementation in Go. It provides a complete OAuth2 authorization server that can be used to secure your APIs and applications.
- OAuth2 authorization server implementation
- Support for standard OAuth2 flows (authorization code, implicit, client credentials, password)
- Authentication and session management
- In-memory storage with interfaces for easy extension to persistent storage
- Simple API for integration
The project follows the standard Go project layout:
authlite/
├── api/ # API definitions
│ └── v1/ # API version 1
├── cmd/ # Application entrypoints
│ └── server/ # OAuth2 server command
├── docs/ # Documentation
├── examples/ # Example usage
├── internal/ # Private application code
│ ├── config/ # Configuration handling
│ └── middleware/# HTTP middleware
├── pkg/ # Public library code
│ ├── auth/ # Authentication
│ ├── oauth2/ # OAuth2 implementation
│ └── storage/ # Storage interfaces
└── web/ # Web assets (templates, static files)
- Go 1.16 or higher
Clone the repository:
git clone https://github.com/tom/authlite.git
cd authlite
go run cmd/server/main.go
The server will start on http://localhost:9000
by default.
For demonstration purposes, a test client is pre-registered with the following credentials:
- Client ID:
test_client
- Client Secret:
test_secret
- Redirect URI:
http://localhost:8080/callback
- Redirect the user to the authorization endpoint:
http://localhost:9000/oauth/authorize?client_id=test_client&redirect_uri=http://localhost:8080/callback&response_type=code&scope=read
- The user will be redirected to log in (use
testuser/password
for demo) - After authorization, the user will be redirected to the specified redirect URI with an authorization code
- Exchange the authorization code for an access token:
curl -X POST http://localhost:9000/oauth/token \
-d "grant_type=authorization_code" \
-d "code=AUTHORIZATION_CODE" \
-d "redirect_uri=http://localhost:8080/callback" \
-d "client_id=test_client" \
-d "client_secret=test_secret"
Use the access token to access protected resources:
curl -H "Authorization: Bearer ACCESS_TOKEN" http://localhost:9000/userinfo
- Implement persistent storage backends
- Add support for JWT tokens
- Add OpenID Connect extensions
- Implement additional security features (PKCE, etc.)
This project is licensed under the MIT License - see the LICENSE file for details.