Help us shape the future of Go! Take the 2026 Go Developer Survey

oidc

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationCodeFlow

type AuthorizationCodeFlow struct {
	Client

	RedirectURI xurl.URL
	// contains filtered or unexported fields
}

func (AuthorizationCodeFlow) BrowserUrl

func (a AuthorizationCodeFlow) BrowserUrl(extraScopes scope.Scopes, askConsent bool) xurl.URL

BrowserUrl asks for the standard scopes plus extraScopes. askConsent makes keycloak show its consent screen even for scopes the user has granted before.

func (AuthorizationCodeFlow) CheckState

func (a AuthorizationCodeFlow) CheckState(state string) error

func (AuthorizationCodeFlow) Exchange

func (a AuthorizationCodeFlow) Exchange(ctx context.Context, code string) (Token, error)

type Client

type Client struct {
	http.Client

	ClientConfig

	Id string
}

func NewClient

func NewClient(ctx context.Context, httpClient http.Client, issuer xurl.URL, clientId string) (Client, error)

func (Client) EndSession

func (c Client) EndSession(ctx context.Context, refreshToken string) error

func (Client) ExchangeAuthCode

func (c Client) ExchangeAuthCode(ctx context.Context, code string, redirectUri xurl.URL, verifier string) (resp Token, err error)

ExchangeAuthCode ends the authorization code flow, see AuthorizationCodeFlow.Exchange.

func (Client) NewAuthorizationCode

func (c Client) NewAuthorizationCode(redirectURI xurl.URL) AuthorizationCodeFlow

func (Client) Refresh

func (c Client) Refresh(ctx context.Context, refreshToken string, scopes scope.Scopes) (resp Token, err error)

type ClientConfig

type ClientConfig struct {
	Issuer                xurl.URL `json:"issuer"`
	AuthorizationEndpoint xurl.URL `json:"authorization_endpoint"`
	TokenEndpoint         xurl.URL `json:"token_endpoint"`
	// Both are optional in the discovery document, and either one ends a session.
	EndSessionEndpoint *xurl.URL `json:"end_session_endpoint"`
	RevocationEndpoint *xurl.URL `json:"revocation_endpoint"`
}

type Token

type Token struct {
	AccessToken  jwt.JWT `json:"access_token"`
	RefreshToken string  `json:"refresh_token"`
	Scope        string  `json:"scope"`
	// RefreshExpiresIn is Keycloak's own field: the seconds left until the refresh token's session
	// ends at the latest, where 0 or its absence means no limit.
	RefreshExpiresIn int64 `json:"refresh_expires_in"`
	// RefreshExpiresAt counts from before the request was sent, so it errs early.
	RefreshExpiresAt time.Time `json:"-"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL