session

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SessionKey = keySession("cat-session")
)

Functions

func NewManager

func NewManager(logger zerolog.Logger, expiration time.Duration, filePath string) (*sessionManager, error)

NewManager creates a new sessionManager with the given logger, expiration duration, and file path. It loads the active sessions from the given file path, and returns an error if the file does not exist or if there is an error loading the sessions.

Types

type JIT added in v0.4.0

type JIT struct {
	sync.Mutex `json:"-" yaml:"-"`
	Config     JITConfig `json:"config" yaml:"config"`
	Users      []User    `json:"users" yaml:"-"`
}

func (*JIT) AddOrUpdateUserFromJWTToken added in v0.4.0

func (j *JIT) AddOrUpdateUserFromJWTToken(token string) error

func (*JIT) AddOrUpdateUserFromSAMLAssertion added in v0.4.0

func (j *JIT) AddOrUpdateUserFromSAMLAssertion(claims samlsp.JWTSessionClaims) error

type JITConfig added in v0.4.0

type JITConfig struct {
	Enabled       bool    `json:"enabled" yaml:"enabled"`
	UpdateOnLogin bool    `json:"update_on_login" yaml:"update_on_login"`
	SAMLMappings  *claims `json:"saml_mappings" yaml:"saml_mappings"`
	OIDCMappings  *claims `json:"oidc_mappings" yaml:"oidc_mappings"`
}

type OidcParams

type OidcParams struct {
	MetadataUrl   string        `json:"metadata_url" yaml:"metadata_url"`
	PublicClient  bool          `json:"public_client" yaml:"public_client"`
	PKCE          bool          `json:"pkce" yaml:"pkce"`
	PKCEData      *pkce.PKCE    `json:"-" yaml:"-"`
	ResponseType  responseType  `json:"response_type" yaml:"response_type"`
	ClientID      string        `json:"client_id" yaml:"client_id"`
	Secret        string        `json:"secret" yaml:"secret"`
	RedirectURI   string        `json:"redirect_uri" yaml:"redirect_uri"`
	Scopes        []string      `json:"scopes" yaml:"scopes"`
	ErrorResponse errorResponse `json:"error_response" yaml:"-"`
}

type SamlParams

type SamlParams struct {
	IdpUrl             string        `json:"idp_url" yaml:"idp_url"`
	SPEntityID         string        `json:"sp_entity_id" yaml:"sp_entity_id"`
	SPMetadataUrl      string        `json:"sp_metadata_url" yaml:"sp_metadata_url"`
	IdpMetadata        string        `json:"idp_metadata" yaml:"-"`
	RequestSigning     bool          `json:"request_signing" yaml:"request_signing"`
	RequestSigningAlgo string        `json:"request_signing_algo" yaml:"request_signing_algo"`
	AddEncryptionCert  bool          `json:"add_encryption_cert" yaml:"add_encryption_cert"`
	AllowIdpInitiated  bool          `json:"allow_idp_initiated" yaml:"allow_idp_initiated"`
	NameIdFormat       string        `json:"name_id_format" yaml:"name_id_format"`
	Certificates       certificates  `json:"certificates" yaml:"certificates"`
	ActiveCert         string        `json:"active_cert" yaml:"active_cert"`
	ErrorResponse      errorResponse `json:"error_response" yaml:"-"`
}

type Session

type Session struct {
	ID         string             `json:"id" yaml:"id"`
	Shared     bool               `json:"shared" yaml:"shared"`
	JIT        JIT                `json:"jit" yaml:"jit"`
	Expires    time.Time          `json:"expires" yaml:"expires"`
	SAMLConfig SamlParams         `json:"saml,omitempty" yaml:"saml,omitempty"`
	OIDCConfig OidcParams         `json:"oidc,omitempty" yaml:"oidc,omitempty"`
	SAMLSP     *samlsp.Middleware `json:"-" yaml:"-"`
	OIDCClient oidcClient         `json:"-" yaml:"-"`
}

func (*Session) Valid

func (s *Session) Valid() bool

Valid returns true if the session has not expired, false otherwise.

type User added in v0.4.0

type User struct {
	ID          string   `json:"id" yaml:"-"`
	Protocol    string   `json:"protocol" yaml:"-"`
	Existing    bool     `json:"-" yaml:"-"`
	DisplayName string   `json:"display_name" yaml:"-"`
	FirstName   string   `json:"first_name" yaml:"-"`
	LastName    string   `json:"last_name" yaml:"-"`
	Email       string   `json:"email" yaml:"-"`
	Roles       []string `json:"roles" yaml:"-"`
}

Jump to

Keyboard shortcuts

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