ss-keel-oauth
ss-keel-oauth provides OAuth2 authentication middleware with support for popular providers. After a successful OAuth flow, the authenticated user profile is stored in the request context via SetUser, compatible with UserAs[T].
Implements: Guard
Planned Installation
Section titled āPlanned Installationāgo get github.com/slice-soft/ss-keel-oauthPlanned Providers
Section titled āPlanned Providersā| Provider | Status |
|---|---|
| Planned | |
| GitHub | Planned |
| Microsoft | Planned |
| Discord | Planned |
| Custom (any OAuth2) | Planned |
Planned Usage
Section titled āPlanned Usageāimport "github.com/slice-soft/ss-keel-oauth"
oauth := ssoauth.New(ssoauth.Config{ Google: &ssoauth.ProviderConfig{ ClientID: os.Getenv("GOOGLE_CLIENT_ID"), ClientSecret: os.Getenv("GOOGLE_CLIENT_SECRET"), RedirectURL: "https://myapp.com/auth/google/callback", Scopes: []string{"email", "profile"}, }, GitHub: &ssoauth.ProviderConfig{ ClientID: os.Getenv("GITHUB_CLIENT_ID"), ClientSecret: os.Getenv("GITHUB_CLIENT_SECRET"), RedirectURL: "https://myapp.com/auth/github/callback", },})
// Register OAuth routes (redirects + callbacks)app.Use(oauth)Accessing the OAuth User
Section titled āAccessing the OAuth Userāfunc callbackHandler(c *core.Ctx) error { profile, ok := core.UserAs[*ssoauth.Profile](c) if !ok { return core.Unauthorized("oauth failed") }
// profile.Provider ā "google", "github" // profile.ID // profile.Email // profile.Name // profile.AvatarURL}Generated Routes
Section titled āGenerated RoutesāThe addon auto-registers:
| Route | Description |
|---|---|
GET /auth/{provider} | Redirect to provider |
GET /auth/{provider}/callback | Handle OAuth callback |