elvid

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: MIT Imports: 10 Imported by: 1

README

ElvID

Test

  • Setup following environment variables.
source_env ${HOME}
export ELVID_ACCESS_TOKEN="ey...."
export ELVID_BASE_URL="https://elvid.test-elvia.io"
export ELVID_CLIENT_ID="00000000-0000-4000-8000-000000000000"
export ELVID_ID_TOKEN="ey...."
export ELVID_MACHINE_CLIENT_ID="00000000-0000-4000-8000-000000000000"
export ELVID_MACHINE_CLIENT_SECRET="...."
export GITHUB_TOKEN="...."
export VAULT_ADDR="https://vault.dev-elvia.io"
go test -v -tags=integration -timeout 0

Documentation

Index

Constants

View Source
const (
	DiscoveryEndpoint           = "/.well-known/openid-configuration"
	JsonWebKeySetEndpoint       = "/.well-known/openid-configuration/jwks"
	AuthorizationEndpoint       = "/connect/authorize"
	TokenEndpoint               = "/connect/token"
	UserInfoEndpoint            = "/connect/userinfo"
	EndSessionEndpoint          = "/connect/endsession"
	CheckSessionEndpoint        = "/connect/checksession"
	RevocationEndpoint          = "/connect/revocation"
	IntrospectionEndpoint       = "/connect/introspect"
	DeviceAuthorizationEndpoint = "/connect/deviceauthorization"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Issuer           string `json:"issuer"`
	JsonWebKeySetUri string `json:"jwks_uri"`
	// AuthorizationEndpoint string `json:"authorization_endpoint"`
	TokenEndPoint string `json:"token_endpoint"`
	// contains filtered or unexported fields
}

Configuration contains the configuration information needed to do the initial setup and renewal of the ElvID service

type ElvID

type ElvID struct {
	Configuration
	PublicKeySet
}

ElvID holds the configurations and keys necessary to communicate with the ElvID service.

func (*ElvID) AuthorizeRequest

func (elvid *ElvID) AuthorizeRequest(r *http.Request, scope string) error

AuthorizeRequest takes an incoming request on behalf of the service and extracts the token from the "Authorization" header. The token is then checked for authenticity, and then the claims of that token is verified against the provided scope.

func (*ElvID) Configure

func (elvid *ElvID) Configure(client libhttp.Client) error

func (*ElvID) ConnectToServer

func (elvid *ElvID) ConnectToServer() error

ConnectToServer performs necessary setup for connections to the external ElvID service

func (*ElvID) GetJsonWebKeySetUri added in v1.3.1

func (elvid *ElvID) GetJsonWebKeySetUri() string

func (ElvID) GetToken

func (elvid ElvID) GetToken(user, secret string) (token *Token, err error)

GetToken provides the credentials of a user or service, and returns a token for sending with requests to a service.

func (ElvID) HasValidUserClientAccessToken added in v1.3.1

func (elvid ElvID) HasValidUserClientAccessToken(accessToken string) (isValid bool, err error)

type IDManager

type IDManager interface {
	GetToken(user, secret string) (token *Token, err error)
	AuthorizeRequest(r *http.Request, scope string) error
	HasValidUserClientAccessToken(accessToken string) (isValid bool, err error)
	GetJsonWebKeySetUri() string
}

IDManager represents a service that is able to provide clients with authorization tokens with the GetToken function, and is capable of authorizing these incoming tokens for the server with the AuthorizeRequest function.

func New

func New() (IDManager, error)

New creates a new ElvID, performs necessary setup, and returns it as an IDManager

type PublicKeySet

type PublicKeySet struct {
	Keys []struct {
		KeyID     string   `json:"kid"`
		Algorithm string   `json:"alg"`
		X5C       []string `json:"x5c"`
	} `json:"keys"`
}

PublicKeySet (Public Key Set) stores a slice of public keys and their metadata

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	ExpiresAt    int    `json:"expires_at"`
	ExpiresIn    int    `json:"expires_in"`
	IdToken      string `json:"id_token"`
	Profile      string `json:"profile"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
	SessionState string `json:"session_state"`
	State        string `json:"state"`
	TokenType    string `json:"token_type"`
}

Token exp

func (Token) AppendToRequest

func (token Token) AppendToRequest(req *http.Request)

Append the raw token to the header of the provided request.

Jump to

Keyboard shortcuts

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