auth

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOAuthTokenSource

func CreateOAuthTokenSource(source oauth2.TokenSource) *oAuthTokenSource

CreateOAuthTokenSource creates an oAuthTokenSource from a ITokenSource from the oauth2 library

Types

type ITokenSource

type ITokenSource interface {
	Token() (*Token, error)
}

ITokenSource interface for creating new auth tokens

func ApiKeyTokenSource

func ApiKeyTokenSource(secret string) (ITokenSource, error)

ApiKeyTokenSource creates a new apiKeyTokenSource for API key authentication

func BasicAuthTokenSource

func BasicAuthTokenSource(clientId string, secret string) (ITokenSource, error)

BasicAuthTokenSource creates a new basicAuthTokenSource for basic authentication

func CreateTokenFromOAuthFlow

func CreateTokenFromOAuthFlow(l logger.Logger, grantType string, clientId string, secret string, flow discovery.OAuthFlow) (ITokenSource, error)

CreateTokenFromOAuthFlow creates a ITokenSource for a OAuthFlow

func CreateTokenSource

func CreateTokenSource(l logger.Logger, schema discovery.SecuritySchema, clientId string, secret string) (ITokenSource, error)

CreateTokenSource creates a new ITokenSource Uses the schema type (BasicSecSchemaType) to create a ITokenSource for the proper auth source

func CreateTokenSourceFromSchemas

func CreateTokenSourceFromSchemas(l logger.Logger, schemas []discovery.SecuritySchema, clientId string, secret string) (ITokenSource, error)

CreateTokenSourceFromSchemas creates a new ITokenSource from the first schema in the slice

type Token

type Token struct {
	AccessToken  string
	TokenType    string
	RefreshToken string
	Expiry       time.Time
}

Token object holding token information

func (*Token) CreateAuthHeader

func (t *Token) CreateAuthHeader(l logger.Logger) http.Header

CreateAuthHeader returns a http Header holding the Authorization header from this token

func (*Token) CreateAuthHeaderValue

func (t *Token) CreateAuthHeaderValue(l logger.Logger) string

CreateAuthHeaderValue creates the value for the Authorization header from this token

func (*Token) SetAuthHeader

func (t *Token) SetAuthHeader(l logger.Logger, r *http.Request)

SetAuthHeader set the authorization header in a http Request using this token

func (*Token) Type

func (t *Token) Type(l logger.Logger) string

Type returns the type of this token formats the TokenType to a value that can be used in the Authorization http header

func (*Token) Valid

func (t *Token) Valid() bool

Valid checks if this token is still valid checks if this token holds a value and isn't expired yet

Jump to

Keyboard shortcuts

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