auth

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AuthorizationHeader = "Authorization"
View Source
const BearerPrefix = "Bearer"

Variables

This section is empty.

Functions

func GetSecuritySchemeUniqueName added in v0.8.3

func GetSecuritySchemeUniqueName(securityScheme *SecurityScheme) string

func NewErrTokenFormatShouldBeJWT added in v0.8.4

func NewErrTokenFormatShouldBeJWT() error

Types

type InCookieValue added in v0.8.4

type InCookieValue = http.Cookie

type InHeaderValue added in v0.8.4

type InHeaderValue = string

type InQueryValue added in v0.8.4

type InQueryValue = string

type OAuthConfig added in v0.6.1

type OAuthConfig struct {
	ClientID     string
	ClientSecret string

	TokenURL   string
	RefreshURL string
}

type OAuthFlow added in v0.6.1

type OAuthFlow string
const (
	AuthorizationCodeFlow OAuthFlow = "authorization_code"
	ImplicitFlow          OAuthFlow = "implicit"
	ClientCredentials     OAuthFlow = "client_credentials"
)

type OAuthValue added in v0.8.4

type OAuthValue struct {
	AccessToken  string     `json:"access_token" yaml:"access_token"`
	RefreshToken *string    `json:"refresh_token" yaml:"refresh_token"`
	ExpiresIn    *time.Time `json:"expires_in" yaml:"expires_in"`
	Scope        *string    `json:"scope" yaml:"scope"`
}

func NewOAuthValue added in v0.8.4

func NewOAuthValue(accessToken string, refreshToken *string, expiresIn *time.Time, scope *string) *OAuthValue

func (*OAuthValue) GetAccessToken added in v0.8.4

func (value *OAuthValue) GetAccessToken() string

func (*OAuthValue) SetAccessToken added in v0.8.4

func (value *OAuthValue) SetAccessToken(accessToken string)

type SchemeIn

type SchemeIn string
const (
	InQuery  SchemeIn = "query"
	InHeader SchemeIn = "header"
	InCookie SchemeIn = "cookie"
)

type SchemeName

type SchemeName string
const (
	BasicScheme  SchemeName = "Basic"
	BearerScheme SchemeName = "Bearer"
	DigestScheme SchemeName = "Digest"
	OAuthScheme  SchemeName = "OAuth"
	PrivateToken SchemeName = "PrivateToken"
	NoneScheme   SchemeName = "None"
)

Values are registred in the IANA Authentication Scheme registry https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml

func (*SchemeName) String

func (s *SchemeName) String() string

func (*SchemeName) Type

func (e *SchemeName) Type() string

type SecurityScheme

type SecurityScheme struct {
	Type        Type         `json:"type" yaml:"type"`
	Scheme      SchemeName   `json:"scheme" yaml:"scheme"`
	In          *SchemeIn    `json:"in" yaml:"in"`
	TokenFormat *TokenFormat `json:"token_format" yaml:"token_format"`

	Name   string      `json:"name" yaml:"name"`
	Config interface{} `json:"config" yaml:"config"`

	ValidValue  interface{} `json:"-" yaml:"-"`
	AttackValue interface{} `json:"-" yaml:"-"`
}

func MustNewAPIKeySecurityScheme added in v0.8.4

func MustNewAPIKeySecurityScheme(name string, in SchemeIn, value *string) *SecurityScheme

func MustNewAuthorizationBearerSecurityScheme added in v0.8.4

func MustNewAuthorizationBearerSecurityScheme(name string, value *string) *SecurityScheme

func MustNewNoAuthSecurityScheme added in v0.8.4

func MustNewNoAuthSecurityScheme() *SecurityScheme

func MustNewOAuthSecurityScheme added in v0.8.4

func MustNewOAuthSecurityScheme(name string, in *SchemeIn, value *OAuthValue, config *OAuthConfig) *SecurityScheme

func NewAPIKeySecurityScheme added in v0.8.4

func NewAPIKeySecurityScheme(name string, in SchemeIn, value *string) (*SecurityScheme, error)

func NewAuthorizationBearerSecurityScheme

func NewAuthorizationBearerSecurityScheme(name string, value *string) (*SecurityScheme, error)

func NewNoAuthSecurityScheme added in v0.3.1

func NewNoAuthSecurityScheme() (*SecurityScheme, error)

func NewOAuthSecurityScheme added in v0.6.1

func NewOAuthSecurityScheme(name string, in *SchemeIn, value *OAuthValue, config *OAuthConfig) (*SecurityScheme, error)

func NewSecurityScheme added in v0.8.4

func NewSecurityScheme(name string, config interface{}, t Type, scheme SchemeName, in *SchemeIn, tokenFormat *TokenFormat) (*SecurityScheme, error)

func (*SecurityScheme) GetAttackValue

func (securityScheme *SecurityScheme) GetAttackValue() interface{}

func (*SecurityScheme) GetConfig added in v0.8.4

func (securityScheme *SecurityScheme) GetConfig() interface{}

func (*SecurityScheme) GetCookies

func (securityScheme *SecurityScheme) GetCookies() []*http.Cookie

func (*SecurityScheme) GetHeaders

func (securityScheme *SecurityScheme) GetHeaders() http.Header

func (*SecurityScheme) GetIn added in v0.8.0

func (securityScheme *SecurityScheme) GetIn() *SchemeIn

func (*SecurityScheme) GetName added in v0.8.0

func (securityScheme *SecurityScheme) GetName() string

func (*SecurityScheme) GetScheme added in v0.8.0

func (securityScheme *SecurityScheme) GetScheme() SchemeName

func (*SecurityScheme) GetToken added in v0.8.4

func (securityScheme *SecurityScheme) GetToken() string

func (*SecurityScheme) GetTokenFormat added in v0.8.4

func (securityScheme *SecurityScheme) GetTokenFormat() *TokenFormat

func (*SecurityScheme) GetType added in v0.8.0

func (securityScheme *SecurityScheme) GetType() Type

func (*SecurityScheme) GetValidValue

func (securityScheme *SecurityScheme) GetValidValue() interface{}

func (*SecurityScheme) HasValidValue added in v0.6.0

func (securityScheme *SecurityScheme) HasValidValue() bool

func (*SecurityScheme) SetAttackValue

func (securityScheme *SecurityScheme) SetAttackValue(value interface{}) error

func (*SecurityScheme) SetTokenFormat added in v0.8.4

func (securityScheme *SecurityScheme) SetTokenFormat(tokenFormat TokenFormat) error

func (*SecurityScheme) SetValidValue added in v0.8.4

func (securityScheme *SecurityScheme) SetValidValue(value interface{}) error

type SecuritySchemesMap added in v0.6.1

type SecuritySchemesMap map[string]*SecurityScheme

type TokenFormat added in v0.8.4

type TokenFormat string
const (
	JWTTokenFormat  TokenFormat = "jwt"
	NoneTokenFormat TokenFormat = "none"
)

type Type

type Type string
const (
	HttpType      Type = "http"
	OAuth2        Type = "oauth2"
	OpenIdConnect Type = "openIdConnect"
	ApiKey        Type = "apiKey"
	MutualTLS     Type = "mutualTLS"
	None          Type = "none"
)

Jump to

Keyboard shortcuts

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