MCPcopy
hub / github.com/coreos/go-oidc

github.com/coreos/go-oidc @v3.19.0 sqlite

repository ↗ · DeepWiki ↗ · release v3.19.0 ↗
127 symbols 401 edges 14 files 46 documented · 36%
README

go-oidc

Go Reference github.com/coreos/go-oidc/v3

Updates from v2 to v3

There were two breaking changes made to the v3 branch. The import path has changed from:

github.com/coreos/go-oidc

to:

github.com/coreos/go-oidc/v3/oidc

And the return type of NewRemoteKeySet() is now *RemoteKeySet instead of an interface (#262).

OpenID Connect support for Go

This package enables OpenID Connect support for the golang.org/x/oauth2 package.

provider, err := oidc.NewProvider(ctx, "https://accounts.google.com")
if err != nil {
    // handle error
}

// Configure an OpenID Connect aware OAuth2 client.
oauth2Config := oauth2.Config{
    ClientID:     clientID,
    ClientSecret: clientSecret,
    RedirectURL:  redirectURL,

    // Discovery returns the OAuth2 endpoints.
    Endpoint: provider.Endpoint(),

    // "openid" is a required scope for OpenID Connect flows.
    Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
}

OAuth2 redirects are unchanged.

func handleRedirect(w http.ResponseWriter, r *http.Request) {
    http.Redirect(w, r, oauth2Config.AuthCodeURL(state), http.StatusFound)
}

The on responses, the provider can be used to verify ID Tokens.

var verifier = provider.Verifier(&oidc.Config{ClientID: clientID})

func handleOAuth2Callback(w http.ResponseWriter, r *http.Request) {
    // Verify state and errors.

    oauth2Token, err := oauth2Config.Exchange(ctx, r.URL.Query().Get("code"))
    if err != nil {
        // handle error
    }

    // Extract the ID Token from OAuth2 token.
    rawIDToken, ok := oauth2Token.Extra("id_token").(string)
    if !ok {
        // handle missing token
    }

    // Parse and verify ID Token payload.
    idToken, err := verifier.Verify(ctx, rawIDToken)
    if err != nil {
        // handle error
    }

    // Extract custom claims
    var claims struct {
        Email    string `json:"email"`
        Verified bool   `json:"email_verified"`
    }
    if err := idToken.Claims(&claims); err != nil {
        // handle error
    }
}

Extension points exported contracts — how you extend this code

KeySet (Interface)
KeySet is a set of publc JSON Web Keys that can be used to validate the signature of JSON web tokens. This is expected t [2 …
oidc/verify.go

Core symbols most depended-on inside this repo

Error
called by 54
oidc/verify.go
verify
called by 12
oidc/jwks.go
Verify
called by 12
oidc/verify.go
NewProvider
called by 8
oidc/oidc.go
newToken
called by 8
oidc/oidctest/oidctest.go
NewVerifier
called by 6
oidc/verify.go
getClient
called by 5
oidc/oidc.go
newRemoteKeySet
called by 5
oidc/jwks.go

Shape

Function 53
Method 43
Struct 26
TypeAlias 4
Interface 1

Languages

Go100%

Modules by API surface

oidc/oidc.go30 symbols
oidc/jwks_test.go18 symbols
oidc/verify.go15 symbols
oidc/jwks.go15 symbols
oidc/oidc_test.go13 symbols
oidc/verify_test.go11 symbols
oidc/oidctest/oidctest.go8 symbols
oidc/logout.go4 symbols
example/logout/app.go4 symbols
example/userinfo/app.go3 symbols
example/idtoken/app.go3 symbols
oidc/logout_test.go2 symbols

Dependencies from manifests, versioned

github.com/go-jose/go-jose/v4v4.1.4 · 1×
golang.org/x/oauth2v0.36.0 · 1×

For agents

$ claude mcp add go-oidc \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact