Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdminRouteConfig ¶ added in v0.0.3
type AdminRouteConfig struct {
// Role management routes
ListRolesPath string
CreateRolePath string
GetRolePath string
UpdateRolePath string
DeleteRolePath string
// Permission management routes
ListPermissionsPath string
CreatePermissionPath string
GetPermissionPath string
UpdatePermissionPath string
DeletePermissionPath string
// User role management routes
AssignUserRolePath string
RemoveUserRolePath string
GetUserRolesPath string
// User permission management routes
GrantUserPermissionPath string
RevokeUserPermissionPath string
GetUserPermissionsPath string
// Role permission management routes
GrantRolePermissionPath string
RevokeRolePermissionPath string
GetRolePermissionsPath string
}
AdminRouteConfig holds HTTP route configuration for admin endpoints
func DefaultAdminRouteConfig ¶ added in v0.0.3
func DefaultAdminRouteConfig() *AdminRouteConfig
DefaultAdminRouteConfig returns admin route configuration with sensible defaults
type Config ¶
type Config struct {
// Database configuration
Database DatabaseConfig
// JWT configuration
JWT JWTConfig
// Password configuration
Password PasswordConfig
// Token configuration
Token TokenConfig
// OAuth configuration (optional)
OAuth OAuthConfig
}
Config holds the configuration for the auth library
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a configuration with sensible defaults
type DatabaseConfig ¶
type DatabaseConfig struct {
// Driver specifies the database driver (mysql, postgres, sqlserver)
Driver DatabaseDriver
// DSN is the data source name (connection string)
DSN string
// MaxOpenConns sets the maximum number of open connections to the database
MaxOpenConns int
// MaxIdleConns sets the maximum number of connections in the idle connection pool
MaxIdleConns int
// ConnMaxLifetime sets the maximum amount of time a connection may be reused
ConnMaxLifetime time.Duration
}
DatabaseConfig holds database connection settings
func (*DatabaseConfig) Validate ¶
func (dc *DatabaseConfig) Validate() error
Validate validates database configuration
type DatabaseDriver ¶
type DatabaseDriver string
DatabaseDriver represents supported database drivers
const ( // MySQL driver MySQL DatabaseDriver = "mysql" // Postgres driver Postgres DatabaseDriver = "postgres" // SQLServer driver SQLServer DatabaseDriver = "sqlserver" )
type GoogleOAuthConfig ¶
type GoogleOAuthConfig struct {
// is the OAuth2 client ID from Google
ClientID string
// ClientSecret is the OAuth2 client secret from Google
ClientSecret string
// RedirectURL is the callback URL after OAuth authentication
RedirectURL string
// Enabled indicates if Google OAuth is enabled
Enabled bool
}
GoogleOAuthConfig holds Google OAuth2 settings
type JWTConfig ¶
type JWTConfig struct {
// Secret is the secret key used to sign JWT tokens
Secret string
// AccessTokenExpiry is the duration for which access tokens are valid
AccessTokenExpiry time.Duration
// Issuer is the issuer claim for JWT tokens
Issuer string
// Audience is the audience claim for JWT tokens
Audience string
}
JWTConfig holds JWT token settings
type OAuthConfig ¶
type OAuthConfig struct {
// Google OAuth settings
Google GoogleOAuthConfig
}
OAuthConfig holds OAuth provider settings
type PasswordConfig ¶
type PasswordConfig struct {
// MinLength is the minimum password length
MinLength int
// BcryptCost is the cost parameter for bcrypt (4-31, default 12)
BcryptCost int
}
PasswordConfig holds password hashing settings
func (*PasswordConfig) Validate ¶
func (pc *PasswordConfig) Validate() error
Validate validates password configuration
type RouteConfig ¶
type RouteConfig struct {
// RegisterPath is the path for user registration endpoint
RegisterPath string
// LoginPath is the path for user login endpoint
LoginPath string
// LogoutPath is the path for user logout endpoint
LogoutPath string
// RefreshPath is the path for token refresh endpoint
RefreshPath string
// ProfilePath is the path for user profile endpoint
ProfilePath string
// ChangePasswordPath is the path for changing password endpoint
ChangePasswordPath string
// RequestPasswordResetPath is the path for requesting password reset
RequestPasswordResetPath string
// ResetPasswordPath is the path for resetting password with token
ResetPasswordPath string
// VerifyEmailPath is the path for email verification endpoint
VerifyEmailPath string
// ResendVerificationPath is the path for resending verification email
ResendVerificationPath string
// GoogleOAuthPath is the path for initiating Google OAuth login
GoogleOAuthPath string
// GoogleOAuthCallbackPath is the path for Google OAuth callback
GoogleOAuthCallbackPath string
// UnlinkGoogleOAuthPath is the path for unlinking Google OAuth account
UnlinkGoogleOAuthPath string
}
RouteConfig holds HTTP route configuration
func DefaultRouteConfig ¶
func DefaultRouteConfig() *RouteConfig
DefaultRouteConfig returns route configuration with sensible defaults
type TokenConfig ¶
type TokenConfig struct {
// RefreshTokenExpiry is the duration for which refresh tokens are valid
RefreshTokenExpiry time.Duration
// RefreshTokenLength is the length of the random refresh token string
RefreshTokenLength int
}
TokenConfig holds refresh token settings
func (*TokenConfig) Validate ¶
func (tc *TokenConfig) Validate() error
Validate validates token configuration