package boot import ( "context" "log/slog" "net/http" "atlas9.dev/c/iam/oidc_provider" ) func initOauth( ctx context.Context, config *Config, mux *http.ServeMux, deps oidc_provider.Deps, ) { if config.OAuth.Google.ClientID != "" { google := oidc_provider.NewGoogleProvider( ctx, config.OAuth.Google.ClientID, config.OAuth.Google.ClientSecret, config.OAuth.Google.RedirectURL, deps, ) // TODO should these into the api package? mux.HandleFunc("GET /auth/google", google.HandleLogin) mux.HandleFunc("GET /auth/google/callback", google.HandleCallback) mux.HandleFunc("POST /auth/google/callback", google.HandleCallback) slog.Info("Google OIDC provider registered") } if config.OAuth.Apple.ClientID != "" { apple := oidc_provider.NewAppleProvider( ctx, config.OAuth.Apple.ClientID, config.OAuth.Apple.ClientSecret, config.OAuth.Apple.RedirectURL, deps, ) mux.HandleFunc("GET /auth/apple", apple.HandleLogin) mux.HandleFunc("GET /auth/apple/callback", apple.HandleCallback) mux.HandleFunc("POST /auth/apple/callback", apple.HandleCallback) slog.Info("Apple OIDC provider registered") } if config.OAuth.GitHub.ClientID != "" { github := oidc_provider.NewGitHubProvider( ctx, config.OAuth.GitHub.ClientID, config.OAuth.GitHub.ClientSecret, config.OAuth.GitHub.RedirectURL, deps, ) mux.HandleFunc("GET /auth/github", github.HandleLogin) mux.HandleFunc("GET /auth/github/callback", github.HandleCallback) mux.HandleFunc("POST /auth/github/callback", github.HandleCallback) slog.Info("GitHub OAuth provider registered") } }