hid

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr    string
	JWKSuri string `json:"jwks_uri"`
	TokenEP string `json:"token_endpoint"`
	// contains filtered or unexported fields
}

Config contains the configuration information needed to do the initial setup and renewal of the HID service

type HID

type HID struct {
	Config
	PKS
}

HID holds the configurations and keys neccessary to communicate with the HID service.

func (*HID) AuthorizeRequest

func (hid *HID) AuthorizeRequest(r *http.Request, audience, 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 thet token is verified against the provided scope and audince.

func (*HID) Configure added in v0.3.9

func (hid *HID) Configure(client libhttp.Client) error

Configure expl

func (*HID) ConnectToServer added in v0.3.9

func (hid *HID) ConnectToServer() error

ConnectToServer performs neccessary setup for connections to the external HID service

func (HID) GetToken

func (hid HID) 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.

type IDManager added in v0.4.0

type IDManager interface {
	GetToken(user, secret string) (token *Token, err error)
	AuthorizeRequest(r *http.Request, audience, scope string) error
}

IDManager represents a service that is able to provide clients with authoriation 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 HID, performs neccessary setup, and returns it as an IDManager

type PKS added in v0.4.0

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

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

type Token

type Token struct {
	Raw   string `json:"access_token"`
	Scope string `json:"scope"`
	Type  string `json:"token_type"`
	Exp   int    `json:"expires_in"`
}

Token exp

func (Token) AppendToRequest added in v0.4.0

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

AppendToRequest is a simple quality of life function that appends 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