Shared Go utilities for Cylonix Manager and Cylonix Supervisor services. This package provides common functionality used across Cylonix's platform components.
- Secure token generation and validation
- Support for multiple token types:
- System Admin tokens
- Admin tokens
- User tokens
- OAuth state tokens
- OAuth code tokens
- OTP tokens
- QR code tokens
- Token caching with PostgreSQL persistence
- Configurable expiration times
- OAuth 2.0 and OpenID Connect support
- Multiple identity provider integrations:
- Apple Sign In
- Microsoft
- GitHub
- JWT token handling
- State management for OAuth flows
- Cryptographically secure random number generation
- Password generation and validation
- Base32 encoding for tokens
- UUID-based identifiers
- Name hashing utilities
go get github.com/cylonix/utils// Create a new user token
userToken := NewUserToken(namespace)
err := userToken.Create(&UserTokenData{
UserID: uuid.New(),
Username: "example",
// ...other fields
})
// Generate OTP code
otpToken := NewOtpToken()
code, err := otpToken.CanSendCode()// Create OAuth state token
stateToken := NewOauthStateToken(namespace)
err := stateToken.Create(&OauthStateTokenData{
Provider: "google",
RedirectURL: "https://example.com/callback",
// ...other fields
})// Generate secure random state token
stateToken := NewStateToken(16)
// Generate secure password
password := NewPassword()// Default cache durations
SysAdmin: 30 minutes
Admin: 30 minutes
User: 24 hours
OTP: 5 minutes
QR Code: 5 minutes
OAuth State: 5 minutes
OAuth Code: 5 minutesRun the test suite:
go test ./... -v- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- This package will be published as a Go module in the future
- Currently used internally by Cylonix services
- API may change before first public release