Skip to content

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

Terminal window
go get github.com/slice-soft/ss-keel-oauth
ProviderStatus
GooglePlanned
GitHubPlanned
MicrosoftPlanned
DiscordPlanned
Custom (any OAuth2)Planned
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)
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
}

The addon auto-registers:

RouteDescription
GET /auth/{provider}Redirect to provider
GET /auth/{provider}/callbackHandle OAuth callback