Skip to main content

OAuth2 Auth

OAuth2 authentication for social login and delegated authorization. Supports any OAuth2 provider (Google, GitHub, etc.).

Usage

import "github.com/Pavan-Silva/go-zen/auth"

oauth2Auth := &auth.OAuth2Auth{
TokenIntrospectionEndpoint: "https://example.com/introspect",
ClientID: "your-client-id",
ClientSecret: "your-client-secret",
}

r.Use(auth.RequireAuth(oauth2Auth))

How It Works

The middleware introspects Bearer tokens against the configured OAuth2 token introspection endpoint. Valid tokens are mapped to a *User via ClaimsFunc (or a default claim-to-user mapping).