Refactor configuration system with centralized type-safe config package
- Create internal/config package with unified config structs and validation - Abstract viper dependency behind config.Loader interface for better testability - Replace manual config parsing and type assertions with type-safe loading - Consolidate AuthConfig, SiteConfig, and DiscoveryConfig into single package - Add comprehensive validation with clear error messages - Remove ~200 lines of duplicate config handling code - Maintain backward compatibility with existing config files
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/coreos/go-oidc/v3/oidc"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/insertr/insertr/internal/config"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
@@ -24,31 +25,10 @@ type UserInfo struct {
|
||||
Provider string `json:"iss,omitempty"`
|
||||
}
|
||||
|
||||
// AuthConfig holds authentication configuration
|
||||
type AuthConfig struct {
|
||||
DevMode bool
|
||||
Provider string
|
||||
JWTSecret string
|
||||
OAuthConfigs map[string]OAuthConfig
|
||||
OIDC *OIDCConfig
|
||||
}
|
||||
|
||||
// OAuthConfig holds OAuth provider configuration
|
||||
type OAuthConfig struct {
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
Scopes []string
|
||||
}
|
||||
|
||||
// OIDCConfig holds OIDC configuration for Authentik
|
||||
type OIDCConfig struct {
|
||||
Endpoint string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RedirectURL string
|
||||
Scopes []string
|
||||
}
|
||||
// Type aliases for backward compatibility
|
||||
type AuthConfig = config.AuthConfig
|
||||
type OAuthConfig = config.OAuthConfig
|
||||
type OIDCConfig = config.OIDCConfig
|
||||
|
||||
// AuthService handles authentication operations
|
||||
type AuthService struct {
|
||||
|
||||
Reference in New Issue
Block a user