session

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 21 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, secret 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 Group added in v0.5.0

type Group struct {
	ID          string `json:"id" yaml:"id"`
	DisplayName string `json:"display_name" yaml:"display_name"`
}

type JITConfig added in v0.4.0

type JITConfig struct {
	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 Provisioning added in v0.5.0

type Provisioning struct {
	sync.Mutex `json:"-" yaml:"-"`
	Users      map[string]User     `json:"users" yaml:"users"`
	Groups     map[string]Group    `json:"groups" yaml:"groups"`
	Config     ProvisioningConfig  `json:"config" yaml:"config"`
	SCIM       *scim2.SCIMInstance `json:"-" yaml:"-"`
}

func (*Provisioning) AddOrUpdateUserFromJWTToken added in v0.5.0

func (p *Provisioning) AddOrUpdateUserFromJWTToken(token string) error

func (*Provisioning) AddOrUpdateUserFromSAMLAssertion added in v0.5.0

func (p *Provisioning) AddOrUpdateUserFromSAMLAssertion(claims samlsp.JWTSessionClaims) error

type ProvisioningConfig added in v0.5.0

type ProvisioningConfig struct {
	Enabled  bool                 `json:"enabled" yaml:"enabled"`
	Strategy ProvisioningStrategy `json:"strategy" yaml:"strategy"`
	JIT      *JITConfig           `json:"jit" yaml:"jit"`
	SCIM     *scimConfig          `json:"scim" yaml:"scim"`
}

type ProvisioningStrategy added in v0.5.0

type ProvisioningStrategy int
const (
	JITProvisioning  ProvisioningStrategy = iota //0
	SCIMProvisioning                             //1
)

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"`
	Provisioning Provisioning       `json:"provisioning" yaml:"provisioning"`
	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:"-"`
	// contains filtered or unexported fields
}

func (*Session) GenerateJWT added in v0.5.0

func (s *Session) GenerateJWT() (string, error)

func (*Session) Valid

func (s *Session) Valid() bool

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

func (*Session) ValidateJWT added in v0.5.0

func (s *Session) ValidateJWT(token string) bool

type User added in v0.4.0

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

Jump to

Keyboard shortcuts

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