authserver

package
v0.0.0-...-200b26a Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package authserver models an OAuth 2.0 Authorization Server

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationServerService

type AuthorizationServerService interface {
	JwksEndpoint() string
	TokenEndpoint() string
	AuthorizationEndpoint() string
	UserInfoEndpoint() string
	KeySet() keyset.KeySet
	SetKeySet(keyset.KeySet)
	GetTokens(authnMethod string, clientID string, clientSecret string, authorizationCode string, redirectURI string, refreshToken string) (*TokenResponse, error)
}

AuthorizationServerService represents an authorization server instance

func New

func New(discoveryEndpoint string) AuthorizationServerService

New creates a RemoteService returning a AuthorizationServerService interface

type DiscoveryConfig

type DiscoveryConfig struct {
	DiscoveryURL string
	Issuer       string `json:"issuer"`
	AuthURL      string `json:"authorization_endpoint"`
	TokenURL     string `json:"token_endpoint"`
	JwksURL      string `json:"jwks_uri"`
	UserInfoURL  string `json:"userinfo_endpoint"`
}

DiscoveryConfig encapsulates the discovery endpoint configuration

func (*DiscoveryConfig) OK

func (c *DiscoveryConfig) OK() error

OK validates the result from a discovery configuration

type RemoteService

type RemoteService struct {
	DiscoveryConfig
	// contains filtered or unexported fields
}

RemoteService represents a remote authentication server Configuration is loaded asynchronously from the discovery endpoint

func (*RemoteService) AuthorizationEndpoint

func (s *RemoteService) AuthorizationEndpoint() string

AuthorizationEndpoint returns the /authorization endpoint of the OAuth server

func (*RemoteService) GetTokens

func (s *RemoteService) GetTokens(authnMethod string, clientID string, clientSecret string, authorizationCode string, redirectURI string, refreshToken string) (*TokenResponse, error)

GetTokens performs a request to the token endpoint

func (*RemoteService) JwksEndpoint

func (s *RemoteService) JwksEndpoint() string

JwksEndpoint returns the /publicKeys endpoint of the OAuth server

func (*RemoteService) KeySet

func (s *RemoteService) KeySet() keyset.KeySet

KeySet returns the instance's keyset

func (*RemoteService) SetKeySet

func (s *RemoteService) SetKeySet(jwks keyset.KeySet)

SetKeySet stores a JWKs in the OAuth server

func (*RemoteService) TokenEndpoint

func (s *RemoteService) TokenEndpoint() string

TokenEndpoint returns the /token endpoint of the OAuth server

func (*RemoteService) UserInfoEndpoint

func (s *RemoteService) UserInfoEndpoint() string

UserInfoEndpoint returns the /userinfo endpoint of the OAuth server

type TokenResponse

type TokenResponse struct {
	// The OAuth 2.0 Access Value
	AccessToken string `json:"access_token"`
	// The OIDC ID Value
	IdentityToken string `json:"id_token"`
	// The OAuth 2.0 Refresh Value
	RefreshToken string `json:"refresh_token"`
	// The token expiration time
	ExpiresIn int `json:"expires_in"`
}

TokenResponse models an OAuth 2.0 /Value endpoint response

func (*TokenResponse) OK

func (r *TokenResponse) OK() error

OK validates a TokenResponse

Directories

Path Synopsis
Package keyset contains entities to control JSON Web Key Sets (JWKS)
Package keyset contains entities to control JSON Web Key Sets (JWKS)

Jump to

Keyboard shortcuts

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