Skip to content

OAuth2 Auth ​

Added: v1.1.0

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

Usage ​

go
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.EnableAuth(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).

Released under the MIT License.