provider

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented     = errors.New("function not implemented")
	ErrAccessTokenExpired = errors.New("access_token expired or unauthorized")
)

Standard errors.

Functions

This section is empty.

Types

type DiscoveryDoc

type DiscoveryDoc struct {
	Issuer                           string   `json:"issuer,omitempty"`
	AuthEndpoint                     string   `json:"authorization_endpoint,omitempty"`
	TokenEndpoint                    string   `json:"token_endpoint,omitempty"`
	UserInfoEndpoint                 string   `json:"userinfo_endpoint,omitempty"`
	RevocationEndpoint               string   `json:"revocation_endpoint,omitempty"`
	JwksURI                          string   `json:"jwks_uri,omitempty"`
	ResponseTypesSupported           []string `json:"response_types_supported,omitempty"`
	SubjectTypesSupported            []string `json:"subject_types_supported,omitempty"`
	IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported,omitempty"`
	ScopesSupported                  []string `json:"scopes_supported,omitempty"`
	TokenEndpointAuthMethods         []string `json:"token_endpoint_auth_methods_supported,omitempty"`
	ClaimsSupported                  []string `json:"claims_supported,omitempty"`
	CodeChallengeMethodsSupported    []string `json:"code_challenge_methods_supported,omitempty"`
}

DiscoveryDoc - parses the output from openid-configuration for example https://accounts.google.com/.well-known/openid-configuration

type KeycloakProvider

type KeycloakProvider struct {
	sync.Mutex
	// contains filtered or unexported fields
}

KeycloakProvider implements Provider interface for KeyCloak Identity Provider.

func (*KeycloakProvider) LoginWithClientID

func (k *KeycloakProvider) LoginWithClientID(clientID, clientSecret string) error

LoginWithClientID is implemented by Keycloak service account support

func (*KeycloakProvider) LoginWithUser

func (k *KeycloakProvider) LoginWithUser(username, password string) error

LoginWithUser authenticates username/password, not needed for Keycloak

func (*KeycloakProvider) LookupUser

func (k *KeycloakProvider) LookupUser(userid string) (User, error)

LookupUser lookup user by their userid.

type Option

type Option func(*KeycloakProvider)

Option is a function type that accepts a pointer Target

func WithAdminURL

func WithAdminURL(url string) Option

WithAdminURL provide admin URL configuration for Keycloak

func WithOpenIDConfig

func WithOpenIDConfig(oeConfig DiscoveryDoc) Option

WithOpenIDConfig provide OpenID Endpoint configuration discovery document

func WithRealm

func WithRealm(realm string) Option

WithRealm provide realm configuration for Keycloak

func WithTransport

func WithTransport(transport *http.Transport) Option

WithTransport provide custom transport

type Provider

type Provider interface {
	LoginWithUser(username, password string) error
	LoginWithClientID(clientID, clientSecret string) error
	LookupUser(userid string) (User, error)
}

Provider implements indentity provider specific admin operations, such as looking up users, fetching additional attributes etc.

func KeyCloak

func KeyCloak(opts ...Option) (Provider, error)

KeyCloak initializes a new keycloak provider

type Token

type Token struct {
	AccessToken string `json:"access_token"`
	Expiry      int    `json:"expires_in"`
}

Token - parses the output from IDP id_token.

type User

type User struct {
	Name    string `json:"username"`
	ID      string `json:"id"`
	Enabled bool   `json:"enabled"`
}

User represents information about user.

Jump to

Keyboard shortcuts

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