backendjwt

package
v0.0.0-...-202847b Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package backendjwt defines the backend configuration options and element slices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigStructure

func NewConfigStructure() (element.Sections, error)

NewConfigStructure global configuration structure for this package. Used in frontend (to display the user all the settings) and in backend (scope checks and default values). See the source code of this function for the overall available sections, groups and fields.

Types

type ConfigSigningMethod

type ConfigSigningMethod struct {
	cfgmodel.Str
}

ConfigSigningMethod signing method type for the JWT.

func NewConfigSigningMethod

func NewConfigSigningMethod(path string, opts ...cfgmodel.Option) ConfigSigningMethod

NewConfigSigningMethod creates a new signing method configuration type.

func (ConfigSigningMethod) Get

Get returns a signing method definied for a scope. Error behaviour: NotImplemented

type Configuration

type Configuration struct {
	*jwt.OptionFactories

	// Disabled if set to true disables the JWT validation.
	// Path: net/jwt/disabled
	Disabled cfgmodel.Bool

	// HmacPassword handles the password. Will panic if you
	// do not set the cfgmodel.Encryptor
	// Path: net/jwt/signing_method
	SigningMethod ConfigSigningMethod

	// Skew defines the time skew duration between verifier and signer.
	// Path: net/jwt/skew
	Skew cfgmodel.Duration

	// Expiration defines the duration in which a token expires.
	// Path: net/jwt/expiration
	Expiration cfgmodel.Duration

	// SingleTokenUsage if enabled a token can only be used once per request.
	// Path: net/jwt/single_usage
	SingleTokenUsage cfgmodel.Bool

	// HmacPassword handles the password. Will panic if you
	// do not set the cfgmodel.Encryptor
	// Path: net/jwt/hmac_password
	HmacPassword cfgmodel.Obscure

	// HmacPasswordPerUser if enable each logged in user will have their own
	// randomly generated password.
	// TODO(cs) think and implement. we also may need a map to map a user to his/her password and a 2nd field in config which defines the claim key for the username.
	// Path: net/jwt/hmac_password_per_user
	HmacPasswordPerUser cfgmodel.Bool

	// RSAKey handles the RSA private key. Will panic if you
	// do not set the cfgmodel.Encryptor
	// Path: net/jwt/rsa_key
	RSAKey cfgmodel.Obscure

	// RSAKeyPassword handles the password for the RSA private key.
	// Will panic if you do not set the cfgmodel.Encryptor
	// Path: net/jwt/rsa_key_password
	RSAKeyPassword cfgmodel.Obscure

	// ECDSAKey handles the ECDSA private key. Will panic if you
	// do not set the cfgmodel.Encryptor
	// Path: net/jwt/ecdsa_key
	ECDSAKey cfgmodel.Obscure

	// ECDSAKeyPassword handles the password for the ECDSA private key.
	// Will panic if you do not set the cfgmodel.Encryptor
	// Path: net/jwt/ecdsa_key_password
	ECDSAKeyPassword cfgmodel.Obscure
}

Configuration just exported for the sake of documentation. See fields for more information.

func New

func New(cfgStruct element.Sections, opts ...cfgmodel.Option) *Configuration

New initializes the backend configuration models containing the cfgpath.Route variable to the appropriate entries in the storage. The argument Sections and opts will be applied to all models.

func (*Configuration) PrepareOptionFactory

func (be *Configuration) PrepareOptionFactory() jwt.OptionFactoryFunc

PrepareOptionFactory creates a closure around the type Backend. The closure will be used during a scoped request to figure out the configuration depending on the incoming scope. An option array will be returned by the closure.

Jump to

Keyboard shortcuts

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