identity

package
v1.0.47 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreditCardAssociations = []*CreditCardAssociation{
	{
		Name:       "American Express",
		CodeName:   "CID",
		CodeFormat: "NNNN",
		Aliases: []string{
			"amex", "AMEX",
		},
	},
	{
		Name: "Diners Club",
		Aliases: []string{
			"diners",
		},
		CodeName:   "Security Code",
		CodeFormat: "NNN",
	},
	{
		Name: "Discover",
		Aliases: []string{
			"discover",
		},
		CodeName:   "CID",
		CodeFormat: "NNN",
	},
	{
		Name: "Mastercard",
		Aliases: []string{
			"mastercard",
		},
		CodeName:   "CVC2",
		CodeFormat: "NNN",
	},
	{
		Name: "Visa",
		Aliases: []string{
			"visa",
		},
		CodeName:   "CVC2",
		CodeFormat: "NNN",
	},
}

CreditCardAssociations is a collection of most popular credit card issuers.

View Source
var CreditCardIssuers = []*CreditCardIssuer{}

CreditCardIssuers is a collection of most popular credit card issuers.

Functions

func NewID

func NewID() string

NewID returns a random ID to be used for user identification.

func Version

func Version() map[string]interface{}

Version returns the version information.

Types

type APIKey

type APIKey struct {
	ID         string    `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Prefix     string    `json:"prefix,omitempty" xml:"prefix,omitempty" yaml:"prefix,omitempty"`
	Usage      string    `json:"usage,omitempty" xml:"usage,omitempty" yaml:"usage,omitempty"`
	Comment    string    `json:"comment,omitempty" xml:"comment,omitempty" yaml:"comment,omitempty"`
	Payload    string    `json:"payload,omitempty" xml:"payload,omitempty" yaml:"payload,omitempty"`
	Expired    bool      `json:"expired,omitempty" xml:"expired,omitempty" yaml:"expired,omitempty"`
	ExpiredAt  time.Time `json:"expired_at,omitempty" xml:"expired_at,omitempty" yaml:"expired_at,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty"`
	Disabled   bool      `json:"disabled,omitempty" xml:"disabled,omitempty" yaml:"disabled,omitempty"`
	DisabledAt time.Time `json:"disabled_at,omitempty" xml:"disabled_at,omitempty" yaml:"disabled_at,omitempty"`
}

APIKey is an API key.

func NewAPIKey

func NewAPIKey(r *requests.Request) (*APIKey, error)

NewAPIKey returns an instance of APIKey.

func (*APIKey) Disable

func (p *APIKey) Disable()

Disable disables APIKey instance.

func (*APIKey) Match

func (p *APIKey) Match(s string) bool

Match returns true when the provided API matches.

type APIKeyBundle

type APIKeyBundle struct {
	// contains filtered or unexported fields
}

APIKeyBundle is a collection of API keys.

func NewAPIKeyBundle

func NewAPIKeyBundle() *APIKeyBundle

NewAPIKeyBundle returns an instance of APIKeyBundle.

func (*APIKeyBundle) Add

func (b *APIKeyBundle) Add(k *APIKey)

Add adds APIKey to APIKeyBundle.

func (*APIKeyBundle) Get

func (b *APIKeyBundle) Get() []*APIKey

Get returns APIKey instances of the APIKeyBundle.

func (*APIKeyBundle) Size

func (b *APIKeyBundle) Size() int

Size returns the number of APIKey instances in APIKeyBundle.

type AttestationObject

type AttestationObject struct {
	AttestationStatement *AttestationStatement `json:"attStmt,omitempty" xml:"attStmt,omitempty" yaml:"attStmt,omitempty"`
	AuthData             *AuthData             `json:"authData,omitempty" xml:"authData,omitempty" yaml:"authData,omitempty"`
	Format               string                `json:"fmt,omitempty" xml:"fmt,omitempty" yaml:"fmt,omitempty"`
}

AttestationObject is Webauthn AttestationObject.

type AttestationStatement

type AttestationStatement struct {
	Algorithm int64  `json:"alg,omitempty" xml:"alg,omitempty" yaml:"alg,omitempty"`
	Signature string `json:"sig,omitempty" xml:"sig,omitempty" yaml:"sig,omitempty"`
	// The string in the first element of the slice contains the certificate associates
	// with the authenticaing device. The following commands allow the viewing of the
	// cerificate. The Subject contains the serial number associated with the device.
	// 1. `echo -n "base64 encoded value" | base64 -d > key.crt`
	// 2. `openssl x509 -in key.crt -inform der -text`
	Certificates []string `json:"x5c,omitempty" xml:"x5c,omitempty" yaml:"x5c,omitempty"`
}

AttestationStatement is AttestationStatement of the Webauthn AttestationObject.

type AuthData

type AuthData struct {
	RelyingPartyID   string          `json:"rpIdHash,omitempty" xml:"rpIdHash,omitempty" yaml:"rpIdHash,omitempty"`
	Flags            map[string]bool `json:"flags,omitempty" xml:"flags,omitempty" yaml:"flags,omitempty"`
	SignatureCounter uint32          `json:"signatureCounter,omitempty" xml:"signatureCounter,omitempty" yaml:"signatureCounter,omitempty"`
	Extensions       interface{}     `json:"extensions,omitempty" xml:"extensions,omitempty" yaml:"extensions,omitempty"`
	CredentialData   *CredentialData `json:"credentialData,omitempty" xml:"credentialData,omitempty" yaml:"credentialData,omitempty"`
}

AuthData is AuthData of the Webauthn AttestationObject.

type ClientData

type ClientData struct {
	Challenge   string `json:"challenge,omitempty" xml:"challenge,omitempty" yaml:"challenge,omitempty"`
	CrossOrigin bool   `json:"crossOrigin,omitempty" xml:"crossOrigin,omitempty" yaml:"crossOrigin,omitempty"`
	Origin      string `json:"origin,omitempty" xml:"origin,omitempty" yaml:"origin,omitempty"`
	Type        string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
}

ClientData represents the contextual bindings of both the WebAuthn Relying Party and the client. It is a key-value mapping whose keys are strings. Values can be any type that has a valid encoding in JSON. Its structure is defined by the following Web IDL.

type CredentialData

type CredentialData struct {
	// The AAGUID of the authenticator.
	AAGUID string `json:"aaguid,omitempty" xml:"aaguid,omitempty" yaml:"aaguid,omitempty"`
	// A probabilistically-unique byte sequence identifying a public key credential source and its authentication assertions.
	CredentialID string `json:"credentialId,omitempty" xml:"credentialId,omitempty" yaml:"credentialId,omitempty"`
	// The credential public key encoded in COSE Key format
	PublicKey map[string]interface{} `json:"publicKey,omitempty" xml:"publicKey,omitempty" yaml:"publicKey,omitempty"`
}

CredentialData is attested credential data. It is a variable-length byte array added to the authenticator data when generating an attestation object for a given credential.

type CreditCard

type CreditCard struct {
	Number      string                 `json:"number,omitempty" xml:"number,omitempty" yaml:"number,omitempty"`
	Issuer      *CreditCardIssuer      `json:"issuer,omitempty" xml:"issuer,omitempty" yaml:"issuer,omitempty"`
	Association *CreditCardAssociation `json:"association,omitempty" xml:"association,omitempty" yaml:"association,omitempty"`
	Code        string                 `json:"code,omitempty" xml:"code,omitempty" yaml:"code,omitempty"`
	ExpiresAt   time.Time              `json:"expires_at,omitempty" xml:"expires_at,omitempty" yaml:"expires_at,omitempty"`
	IssuedAt    time.Time              `json:"issued_at,omitempty" xml:"issued_at,omitempty" yaml:"issued_at,omitempty"`
}

CreditCard represents a credit card.

func NewCreditCard

func NewCreditCard() *CreditCard

NewCreditCard returns an instance of CreditCard

func (*CreditCard) AddAssociation

func (cc *CreditCard) AddAssociation(s string) error

AddAssociation adds the name of the association, e.g. Visa, American Express, etc., to a credit card

func (*CreditCard) AddIssuer

func (cc *CreditCard) AddIssuer(s string) error

AddIssuer adds the name of the issuer, e.g. CitiGroup, CapitalOne, etc.

type CreditCardAssociation

type CreditCardAssociation struct {
	Name       string   `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Aliases    []string `json:"aliases,omitempty" xml:"aliases,omitempty" yaml:"aliases,omitempty"`
	CodeName   string   `json:"code_name,omitempty" xml:"code_name,omitempty" yaml:"code_name,omitempty"`
	CodeFormat string   `json:"code_format,omitempty" xml:"code_format,omitempty" yaml:"code_format,omitempty"`
}

CreditCardAssociation represents a credit card association, e.g. Visa, American Express, etc., to a credit card

func NewCreditCardAssociation

func NewCreditCardAssociation() *CreditCardAssociation

NewCreditCardAssociation returns an instance of

type CreditCardIssuer

type CreditCardIssuer struct {
	Name    string   `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Aliases []string `json:"aliases,omitempty" xml:"aliases,omitempty" yaml:"aliases,omitempty"`
}

CreditCardIssuer represents the issuer, e.g. Visa, American Express, etc.

func NewCreditCardIssuer

func NewCreditCardIssuer() *CreditCardIssuer

NewCreditCardIssuer returns an instance of

type Database

type Database struct {
	Version      string    `json:"version,omitempty" xml:"version,omitempty" yaml:"version,omitempty"`
	Policy       Policy    `json:"policy,omitempty" xml:"policy,omitempty" yaml:"policy,omitempty"`
	Revision     uint64    `json:"revision,omitempty" xml:"revision,omitempty" yaml:"revision,omitempty"`
	LastModified time.Time `json:"last_modified,omitempty" xml:"last_modified,omitempty" yaml:"last_modified,omitempty"`
	Users        []*User   `json:"users,omitempty" xml:"users,omitempty" yaml:"users,omitempty"`
	// contains filtered or unexported fields
}

Database is user identity database.

func NewDatabase

func NewDatabase(fp string) (*Database, error)

NewDatabase return an instance of Database.

func (*Database) AddAPIKey

func (db *Database) AddAPIKey(r *requests.Request) error

AddAPIKey adds API key for a user.

func (*Database) AddMfaToken

func (db *Database) AddMfaToken(r *requests.Request) error

AddMfaToken adds MFA token for a user.

func (*Database) AddPublicKey

func (db *Database) AddPublicKey(r *requests.Request) error

AddPublicKey adds public key, e.g. GPG or SSH, for a user.

func (*Database) AddUser

func (db *Database) AddUser(r *requests.Request) error

AddUser adds user identity to the database.

func (*Database) AuthenticateUser

func (db *Database) AuthenticateUser(r *requests.Request) error

AuthenticateUser adds user identity to the database.

func (*Database) ChangeUserPassword

func (db *Database) ChangeUserPassword(r *requests.Request) error

ChangeUserPassword change user password.

func (*Database) Copy

func (db *Database) Copy(fp string) error

Copy copies the database to another file.

func (*Database) DeleteAPIKey

func (db *Database) DeleteAPIKey(r *requests.Request) error

DeleteAPIKey deletes an API key associated with a user by key id.

func (*Database) DeleteMfaToken

func (db *Database) DeleteMfaToken(r *requests.Request) error

DeleteMfaToken deletes MFA token associated with a user by token id.

func (*Database) DeletePublicKey

func (db *Database) DeletePublicKey(r *requests.Request) error

DeletePublicKey deletes a public key associated with a user by key id.

func (*Database) DeleteUser

func (db *Database) DeleteUser(r *requests.Request) error

DeleteUser deletes a user by user id.

func (*Database) GetAPIKeys

func (db *Database) GetAPIKeys(r *requests.Request) error

GetAPIKeys returns a list of API keys associated with a user.

func (*Database) GetAdminUserCount

func (db *Database) GetAdminUserCount() int

GetAdminUserCount returns user count.

func (*Database) GetMfaTokens

func (db *Database) GetMfaTokens(r *requests.Request) error

GetMfaTokens returns a list of MFA tokens associated with a user.

func (*Database) GetPasswordPolicyRegex

func (db *Database) GetPasswordPolicyRegex() string

GetPasswordPolicyRegex returns regex for passwords.

func (*Database) GetPasswordPolicySummary

func (db *Database) GetPasswordPolicySummary() string

GetPasswordPolicySummary returns the summary of password policy.

func (*Database) GetPath

func (db *Database) GetPath() string

GetPath returns the path to Database.

func (*Database) GetPublicKeys

func (db *Database) GetPublicKeys(r *requests.Request) error

GetPublicKeys returns a list of public keys associated with a user.

func (*Database) GetUser

func (db *Database) GetUser(r *requests.Request) error

GetUser return an instance of User.

func (*Database) GetUserCount

func (db *Database) GetUserCount() int

GetUserCount returns user count.

func (*Database) GetUsernamePolicyRegex

func (db *Database) GetUsernamePolicyRegex() string

GetUsernamePolicyRegex returns regex for usernames.

func (*Database) GetUsernamePolicySummary

func (db *Database) GetUsernamePolicySummary() string

GetUsernamePolicySummary returns the summary of username policy.

func (*Database) GetUsers

func (db *Database) GetUsers(r *requests.Request) error

GetUsers return a list of user identities.

func (*Database) IdentifyUser

func (db *Database) IdentifyUser(r *requests.Request) error

IdentifyUser returns user identity and a list of challenges that should be satisfied prior to successfully authenticating a user.

func (*Database) LookupAPIKey

func (db *Database) LookupAPIKey(r *requests.Request) error

LookupAPIKey returns username and email associated with the provided API key.

func (*Database) Save

func (db *Database) Save() error

Save saves the database.

func (*Database) UpdateUserPassword

func (db *Database) UpdateUserPassword(r *requests.Request) error

UpdateUserPassword change user password.

func (*Database) UserExists

func (db *Database) UserExists(username, emailAddress string) (bool, error)

UserExists checks whether user exists.

type Device

type Device struct {
	Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Type string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
}

Device is the hardware device on which the WebAuthn Client runs, for example a smartphone, a laptop computer or a desktop computer, and the operating system running on that hardware.

type EmailAddress

type EmailAddress struct {
	Address   string `json:"address,omitempty" xml:"address,omitempty" yaml:"address,omitempty"`
	Confirmed bool   `json:"confirmed,omitempty" xml:"confirmed,omitempty" yaml:"confirmed,omitempty"`
	Domain    string `json:"domain,omitempty" xml:"domain,omitempty" yaml:"domain,omitempty"`
	// contains filtered or unexported fields
}

EmailAddress is an instance of email address

func NewEmailAddress

func NewEmailAddress(s string) (*EmailAddress, error)

NewEmailAddress returns an instance of EmailAddress.

func (*EmailAddress) Primary

func (m *EmailAddress) Primary() bool

Primary returns true is the email is a primary email.

func (*EmailAddress) ToString

func (m *EmailAddress) ToString() string

ToString returns string representation of an email address.

type Handle

type Handle struct {
	Github  string `json:"github,omitempty" xml:"github,omitempty" yaml:"github,omitempty"`
	Twitter string `json:"twitter,omitempty" xml:"twitter,omitempty" yaml:"twitter,omitempty"`
}

Handle is the name associated with online services, e.g. Github, Twitter, etc.

func NewHandle

func NewHandle() *Handle

NewHandle returns an instance of Handle

type Image

type Image struct {
	Title string `json:"title,omitempty" xml:"title,omitempty" yaml:"title,omitempty"`
	// Encoded Base64 string
	Body   string       `json:"body,omitempty" xml:"body,omitempty" yaml:"body,omitempty"`
	Config image.Config `json:"config,omitempty" xml:"config,omitempty" yaml:"config,omitempty"`
	Path   string       `json:"path,omitempty" xml:"path,omitempty" yaml:"path,omitempty"`
}

Image is base64 image

func NewImage

func NewImage() *Image

NewImage returns an instance of Image.

type Location

type Location struct {
	Street      string `json:"street,omitempty" xml:"street,omitempty" yaml:"street,omitempty"`
	City        string `json:"city,omitempty" xml:"city,omitempty" yaml:"city,omitempty"`
	State       string `json:"state,omitempty" xml:"state,omitempty" yaml:"state,omitempty"`
	ZipCode     string `json:"zip_code,omitempty" xml:"zip_code,omitempty" yaml:"zip_code,omitempty"`
	Confirmed   bool   `json:"confirmed,omitempty" xml:"confirmed,omitempty" yaml:"confirmed,omitempty"`
	Current     bool   `json:"current,omitempty" xml:"current,omitempty" yaml:"current,omitempty"`
	Domicile    bool   `json:"domicile,omitempty" xml:"domicile,omitempty" yaml:"domicile,omitempty"`
	Residential bool   `json:"residential,omitempty" xml:"residential,omitempty" yaml:"residential,omitempty"`
	Commercial  bool   `json:"commercial,omitempty" xml:"commercial,omitempty" yaml:"commercial,omitempty"`
}

Location repsents a location, e.g. street address.

func NewLocation

func NewLocation() *Location

NewLocation returns an instance of Location.

type LockoutState

type LockoutState struct {
	Enabled   bool      `json:"enabled,omitempty" xml:"enabled,omitempty" yaml:"enabled,omitempty"`
	StartTime time.Time `json:"start_time,omitempty" xml:"start_time,omitempty" yaml:"start_time,omitempty"`
	EndTime   time.Time `json:"end_time,omitempty" xml:"end_time,omitempty" yaml:"end_time,omitempty"`
}

LockoutState indicates whether user identity is temporarily disabled. If the identity is lockedout, when does the lockout end.

func NewLockoutState

func NewLockoutState() *LockoutState

NewLockoutState returns an instance of LockoutState.

type MfaDevice

type MfaDevice struct {
	Name   string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Vendor string `json:"vendor,omitempty" xml:"vendor,omitempty" yaml:"vendor,omitempty"`
	Type   string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
}

MfaDevice is the hardware device associated with MfaToken.

type MfaToken

type MfaToken struct {
	ID               string            `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Type             string            `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
	Algorithm        string            `json:"algorithm,omitempty" xml:"algorithm,omitempty" yaml:"algorithm,omitempty"`
	Comment          string            `json:"comment,omitempty" xml:"comment,omitempty" yaml:"comment,omitempty"`
	Secret           string            `json:"secret,omitempty" xml:"secret,omitempty" yaml:"secret,omitempty"`
	Period           int               `json:"period,omitempty" xml:"period,omitempty" yaml:"period,omitempty"`
	Digits           int               `json:"digits,omitempty" xml:"digits,omitempty" yaml:"digits,omitempty"`
	Expired          bool              `json:"expired,omitempty" xml:"expired,omitempty" yaml:"expired,omitempty"`
	ExpiredAt        time.Time         `json:"expired_at,omitempty" xml:"expired_at,omitempty" yaml:"expired_at,omitempty"`
	CreatedAt        time.Time         `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty"`
	Disabled         bool              `json:"disabled,omitempty" xml:"disabled,omitempty" yaml:"disabled,omitempty"`
	DisabledAt       time.Time         `json:"disabled_at,omitempty" xml:"disabled_at,omitempty" yaml:"disabled_at,omitempty"`
	Device           *MfaDevice        `json:"device,omitempty" xml:"device,omitempty" yaml:"device,omitempty"`
	Parameters       map[string]string `json:"parameters,omitempty" xml:"parameters,omitempty" yaml:"parameters,omitempty"`
	Flags            map[string]bool   `json:"flags,omitempty" xml:"flags,omitempty" yaml:"flags,omitempty"`
	SignatureCounter uint32            `json:"signature_counter,omitempty" xml:"signature_counter,omitempty" yaml:"signature_counter,omitempty"`
	// contains filtered or unexported fields
}

MfaToken is a puiblic key in a public-private key pair.

func NewMfaToken

func NewMfaToken(req *requests.Request) (*MfaToken, error)

NewMfaToken returns an instance of MfaToken.

func (*MfaToken) Disable

func (p *MfaToken) Disable()

Disable disables MfaToken instance.

func (*MfaToken) ValidateCode

func (p *MfaToken) ValidateCode(code string) error

ValidateCode validates a passcode

func (*MfaToken) ValidateCodeWithTime

func (p *MfaToken) ValidateCodeWithTime(code string, ts time.Time) error

ValidateCodeWithTime validates a passcode at a particular time.

func (*MfaToken) WebAuthnRequest

func (p *MfaToken) WebAuthnRequest(payload string) (*WebAuthnAuthenticateRequest, error)

WebAuthnRequest processes WebAuthn requests.

type MfaTokenBundle

type MfaTokenBundle struct {
	// contains filtered or unexported fields
}

MfaTokenBundle is a collection of public keys.

func NewMfaTokenBundle

func NewMfaTokenBundle() *MfaTokenBundle

NewMfaTokenBundle returns an instance of MfaTokenBundle.

func (*MfaTokenBundle) Add

func (b *MfaTokenBundle) Add(k *MfaToken)

Add adds MfaToken to MfaTokenBundle.

func (*MfaTokenBundle) Get

func (b *MfaTokenBundle) Get() []*MfaToken

Get returns MfaToken instances of the MfaTokenBundle.

func (*MfaTokenBundle) Size

func (b *MfaTokenBundle) Size() int

Size returns the number of MfaToken instances in MfaTokenBundle.

type Name

type Name struct {
	First     string `json:"first,omitempty" xml:"first,omitempty" yaml:"first,omitempty"`
	Last      string `json:"last,omitempty" xml:"last,omitempty" yaml:"last,omitempty"`
	Middle    string `json:"middle,omitempty" xml:"middle,omitempty" yaml:"middle,omitempty"`
	Preferred string `json:"preferred,omitempty" xml:"preferred,omitempty" yaml:"preferred,omitempty"`
	Nickname  bool   `json:"nickname,omitempty" xml:"nickname,omitempty" yaml:"nickname,omitempty"`
	Confirmed bool   `json:"confirmed,omitempty" xml:"confirmed,omitempty" yaml:"confirmed,omitempty"`
	Primary   bool   `json:"primary,omitempty" xml:"primary,omitempty" yaml:"primary,omitempty"`
	Legal     bool   `json:"legal,omitempty" xml:"legal,omitempty" yaml:"legal,omitempty"`
	Alias     bool   `json:"alias,omitempty" xml:"alias,omitempty" yaml:"alias,omitempty"`
}

Name represents human name

func NewName

func NewName() *Name

NewName returns an instance of Name.

func ParseName

func ParseName(s string) (*Name, error)

ParseName parses name from input.

func (*Name) GetFullName

func (n *Name) GetFullName() string

GetFullName returns the primary full name for User.

func (*Name) GetNameClaim

func (n *Name) GetNameClaim() string

GetNameClaim returns name field of a claim.

func (*Name) ToString

func (n *Name) ToString() string

ToString returns string represenation of name.

type Organization

type Organization struct {
	ID      uint64   `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Name    string   `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Aliases []string `json:"aliases,omitempty" xml:"aliases,omitempty" yaml:"aliases,omitempty"`
}

Organization is an organized body of people with a particular purpose.

func NewOrganization

func NewOrganization() *Organization

NewOrganization returns an instance of Organization.

type Password

type Password struct {
	Purpose    string    `json:"purpose,omitempty" xml:"purpose,omitempty" yaml:"purpose,omitempty"`
	Algorithm  string    `json:"algorithm,omitempty" xml:"algorithm,omitempty" yaml:"algorithm,omitempty"`
	Hash       string    `json:"hash,omitempty" xml:"hash,omitempty" yaml:"hash,omitempty"`
	Cost       int       `json:"cost,omitempty" xml:"cost,omitempty" yaml:"cost,omitempty"`
	Expired    bool      `json:"expired,omitempty" xml:"expired,omitempty" yaml:"expired,omitempty"`
	ExpiredAt  time.Time `json:"expired_at,omitempty" xml:"expired_at,omitempty" yaml:"expired_at,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty"`
	Disabled   bool      `json:"disabled,omitempty" xml:"disabled,omitempty" yaml:"disabled,omitempty"`
	DisabledAt time.Time `json:"disabled_at,omitempty" xml:"disabled_at,omitempty" yaml:"disabled_at,omitempty"`
}

Password is a memorized secret, typically a string of characters, used to confirm the identity of a user.

func NewPassword

func NewPassword(s string) (*Password, error)

NewPassword returns an instance of Password.

func NewPasswordWithOptions

func NewPasswordWithOptions(s, purpose, algo string, params map[string]interface{}) (*Password, error)

NewPasswordWithOptions returns an instance of Password based on the provided parameters.

func (*Password) Disable

func (p *Password) Disable()

Disable disables Password instance.

func (*Password) Match

func (p *Password) Match(s string) bool

Match returns true when the provided password matches the user.

type PasswordPolicy

type PasswordPolicy struct {
	KeepVersions           int  `json:"keep_versions" xml:"keep_versions" yaml:"keep_versions"`
	MinLength              int  `json:"min_length" xml:"min_length" yaml:"min_length"`
	MaxLength              int  `json:"max_length" xml:"max_length" yaml:"max_length"`
	RequireUppercase       bool `json:"require_uppercase" xml:"require_uppercase" yaml:"require_uppercase"`
	RequireLowercase       bool `json:"require_lowercase" xml:"require_lowercase" yaml:"require_lowercase"`
	RequireNumber          bool `json:"require_number" xml:"require_number" yaml:"require_number"`
	RequireNonAlphaNumeric bool `json:"require_non_alpha_numeric" xml:"require_non_alpha_numeric" yaml:"require_non_alpha_numeric"`
	BlockReuse             bool `json:"block_reuse" xml:"block_reuse" yaml:"block_reuse"`
	BlockPasswordChange    bool `json:"block_password_change" xml:"block_password_change" yaml:"block_password_change"`
}

PasswordPolicy represents database password policy.

type Policy

type Policy struct {
	Password PasswordPolicy `json:"password,omitempty" xml:"password,omitempty" yaml:"password,omitempty"`
	User     UserPolicy     `json:"user,omitempty" xml:"user,omitempty" yaml:"user,omitempty"`
}

Policy represents database usage policy.

type PublicKey

type PublicKey struct {
	ID    string `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Usage string `json:"usage,omitempty" xml:"usage,omitempty" yaml:"usage,omitempty"`
	// Type is any of the following: dsa, rsa, ecdsa, ed25519
	Type           string    `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
	Fingerprint    string    `json:"fingerprint,omitempty" xml:"fingerprint,omitempty" yaml:"fingerprint,omitempty"`
	FingerprintMD5 string    `json:"fingerprint_md5,omitempty" xml:"fingerprint_md5,omitempty" yaml:"fingerprint_md5,omitempty"`
	Comment        string    `json:"comment,omitempty" xml:"comment,omitempty" yaml:"comment,omitempty"`
	Payload        string    `json:"payload,omitempty" xml:"payload,omitempty" yaml:"payload,omitempty"`
	OpenSSH        string    `json:"openssh,omitempty" xml:"openssh,omitempty" yaml:"openssh,omitempty"`
	Expired        bool      `json:"expired,omitempty" xml:"expired,omitempty" yaml:"expired,omitempty"`
	ExpiredAt      time.Time `json:"expired_at,omitempty" xml:"expired_at,omitempty" yaml:"expired_at,omitempty"`
	CreatedAt      time.Time `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty"`
	Disabled       bool      `json:"disabled,omitempty" xml:"disabled,omitempty" yaml:"disabled,omitempty"`
	DisabledAt     time.Time `json:"disabled_at,omitempty" xml:"disabled_at,omitempty" yaml:"disabled_at,omitempty"`
}

PublicKey is a puiblic key in a public-private key pair.

func NewPublicKey

func NewPublicKey(r *requests.Request) (*PublicKey, error)

NewPublicKey returns an instance of PublicKey.

func (*PublicKey) Disable

func (p *PublicKey) Disable()

Disable disables PublicKey instance.

type PublicKeyBundle

type PublicKeyBundle struct {
	// contains filtered or unexported fields
}

PublicKeyBundle is a collection of public keys.

func NewPublicKeyBundle

func NewPublicKeyBundle() *PublicKeyBundle

NewPublicKeyBundle returns an instance of PublicKeyBundle.

func (*PublicKeyBundle) Add

func (b *PublicKeyBundle) Add(k *PublicKey)

Add adds PublicKey to PublicKeyBundle.

func (*PublicKeyBundle) Get

func (b *PublicKeyBundle) Get() []*PublicKey

Get returns PublicKey instances of the PublicKeyBundle.

func (*PublicKeyBundle) Size

func (b *PublicKeyBundle) Size() int

Size returns the number of PublicKey instances in PublicKeyBundle.

type Registration

type Registration struct {
	ID         string    `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	CreatedAt  time.Time `json:"created_at,omitempty" xml:"created_at,omitempty" yaml:"created_at,omitempty"`
	ApprovedAt time.Time `json:"approved_at,omitempty" xml:"approved_at,omitempty" yaml:"approved_at,omitempty"`
	Approved   bool      `json:"approved,omitempty" xml:"approved,omitempty" yaml:"approved,omitempty"`
	DeclinedAt time.Time `json:"declined_at,omitempty" xml:"declined_at,omitempty" yaml:"declined_at,omitempty"`
	Declined   bool      `json:"declined,omitempty" xml:"declined,omitempty" yaml:"declined,omitempty"`
}

Registration is an instance of user registration. Typically used in scenarios where user wants to register for a service. The user provides identity information and waits for an approval.

func NewRegistration

func NewRegistration(s string) *Registration

NewRegistration returns an instance of Registration.

func (*Registration) Approve

func (r *Registration) Approve()

Approve approves the Registration.

func (*Registration) Decline

func (r *Registration) Decline()

Decline declines the Registration.

type Role

type Role struct {
	Name         string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Organization string `json:"organization,omitempty" xml:"organization,omitempty" yaml:"organization,omitempty"`
}

Role is the user role or entitlement in a system.

func NewRole

func NewRole(s string) (*Role, error)

NewRole returns an instance of Role.

func (*Role) String

func (r *Role) String() string

String returns string representation of Role instance.

type User

type User struct {
	ID             string          `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Enabled        bool            `json:"enabled,omitempty" xml:"enabled,omitempty" yaml:"enabled,omitempty"`
	Human          bool            `json:"human,omitempty" xml:"human,omitempty" yaml:"human,omitempty"`
	Username       string          `json:"username,omitempty" xml:"username,omitempty" yaml:"username,omitempty"`
	Title          string          `json:"title,omitempty" xml:"title,omitempty" yaml:"title,omitempty"`
	Name           *Name           `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Organization   *Organization   `json:"organization,omitempty" xml:"organization,omitempty" yaml:"organization,omitempty"`
	Names          []*Name         `json:"names,omitempty" xml:"names,omitempty" yaml:"names,omitempty"`
	Organizations  []*Organization `json:"organizations,omitempty" xml:"organizations,omitempty" yaml:"organizations,omitempty"`
	StreetAddress  []*Location     `json:"street_address,omitempty" xml:"street_address,omitempty" yaml:"street_address,omitempty"`
	EmailAddress   *EmailAddress   `json:"email_address,omitempty" xml:"email_address,omitempty" yaml:"email_address,omitempty"`
	EmailAddresses []*EmailAddress `json:"email_addresses,omitempty" xml:"email_addresses,omitempty" yaml:"email_addresses,omitempty"`
	Passwords      []*Password     `json:"passwords,omitempty" xml:"passwords,omitempty" yaml:"passwords,omitempty"`
	PublicKeys     []*PublicKey    `json:"public_keys,omitempty" xml:"public_keys,omitempty" yaml:"public_keys,omitempty"`
	APIKeys        []*APIKey       `json:"api_keys,omitempty" xml:"api_keys,omitempty" yaml:"api_keys,omitempty"`
	MfaTokens      []*MfaToken     `json:"mfa_tokens,omitempty" xml:"mfa_tokens,omitempty" yaml:"mfa_tokens,omitempty"`
	Lockout        *LockoutState   `json:"lockout,omitempty" xml:"lockout,omitempty" yaml:"lockout,omitempty"`
	Avatar         *Image          `json:"avatar,omitempty" xml:"avatar,omitempty" yaml:"avatar,omitempty"`
	Created        time.Time       `json:"created,omitempty" xml:"created,omitempty" yaml:"created,omitempty"`
	LastModified   time.Time       `json:"last_modified,omitempty" xml:"last_modified,omitempty" yaml:"last_modified,omitempty"`
	Revision       int             `json:"revision,omitempty" xml:"revision,omitempty" yaml:"revision,omitempty"`
	Roles          []*Role         `json:"roles,omitempty" xml:"roles,omitempty" yaml:"roles,omitempty"`
	Registration   *Registration   `json:"registration,omitempty" xml:"registration,omitempty" yaml:"registration,omitempty"`
	// contains filtered or unexported fields
}

User is a user identity.

func NewUser

func NewUser(s string) *User

NewUser returns an instance of User.

func NewUserWithRoles

func NewUserWithRoles(username, password, email, fullName string, roles []string) (*User, error)

NewUserWithRoles returns User with additional fields.

func (*User) AddAPIKey

func (user *User) AddAPIKey(r *requests.Request) error

AddAPIKey adds API key to a user identity.

func (*User) AddEmailAddress

func (user *User) AddEmailAddress(s string) error

AddEmailAddress returns creates and adds password for a user identity.

func (*User) AddMfaToken

func (user *User) AddMfaToken(r *requests.Request) error

AddMfaToken adds MFA token to a user identity.

func (*User) AddName

func (user *User) AddName(name *Name) error

AddName adds Name for a user identity.

func (*User) AddPassword

func (user *User) AddPassword(s string, keepVersions int) error

AddPassword returns creates and adds password for a user identity.

func (*User) AddPublicKey

func (user *User) AddPublicKey(r *requests.Request) error

AddPublicKey adds public key, e.g. GPG or SSH, to a user identity.

func (*User) AddRole

func (user *User) AddRole(s string) error

AddRole adds a role to a user identity.

func (*User) AddRoles

func (user *User) AddRoles(roles []string) error

AddRoles adds roles to a user identity.

func (*User) ChangePassword

func (user *User) ChangePassword(r *requests.Request, keepVersions int) error

ChangePassword changes user password.

func (*User) DeleteAPIKey

func (user *User) DeleteAPIKey(r *requests.Request) error

DeleteAPIKey deletes an API key associated with a user.

func (*User) DeleteMfaToken

func (user *User) DeleteMfaToken(r *requests.Request) error

DeleteMfaToken deletes MFA token associated with a user.

func (*User) DeletePublicKey

func (user *User) DeletePublicKey(r *requests.Request) error

DeletePublicKey deletes a public key associated with a user.

func (*User) GetChallenges

func (user *User) GetChallenges() []string

GetChallenges returns a list of challenges that should be satisfied prior to successfully authenticating a user.

func (*User) GetFlags

func (user *User) GetFlags(r *requests.Request)

GetFlags populates request context with metadata about a user.

func (*User) GetFullName

func (user *User) GetFullName() string

GetFullName returns the primary full name for a user.

func (*User) GetMailClaim

func (user *User) GetMailClaim() string

GetMailClaim returns primary email address.

func (*User) GetMetadata

func (user *User) GetMetadata() *UserMetadata

GetMetadata returns user metadata.

func (*User) GetNameClaim

func (user *User) GetNameClaim() string

GetNameClaim returns name field of a claim.

func (*User) GetRolesClaim

func (user *User) GetRolesClaim() []string

GetRolesClaim returns name field of a claim.

func (*User) HasAdminRights

func (user *User) HasAdminRights() bool

HasAdminRights returns true if the user has admin rights.

func (*User) HasEmailAddresses

func (user *User) HasEmailAddresses() bool

HasEmailAddresses checks whether a user has email address.

func (*User) HasRole

func (user *User) HasRole(s string) bool

HasRole checks whether a user has a specific role.

func (*User) HasRoles

func (user *User) HasRoles() bool

HasRoles checks whether a user has a role.

func (*User) LookupAPIKey

func (user *User) LookupAPIKey(r *requests.Request) error

LookupAPIKey performs the lookup of API key.

func (*User) Revise

func (user *User) Revise()

Revise increments revision number and last modified timestamp.

func (*User) UpdatePassword

func (user *User) UpdatePassword(r *requests.Request, keepVersions int) error

UpdatePassword update user password.

func (*User) Valid

func (user *User) Valid() error

Valid returns true if a user conforms to a standard.

func (*User) VerifyPassword

func (user *User) VerifyPassword(s string) error

VerifyPassword verifies provided password matches to the one in the database.

func (*User) VerifyWebAuthnRequest

func (user *User) VerifyWebAuthnRequest(r *requests.Request) error

VerifyWebAuthnRequest authenticated WebAuthn requests.

type UserMetadata

type UserMetadata struct {
	ID           string    `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Enabled      bool      `json:"enabled,omitempty" xml:"enabled,omitempty" yaml:"enabled,omitempty"`
	Username     string    `json:"username,omitempty" xml:"username,omitempty" yaml:"username,omitempty"`
	Title        string    `json:"title,omitempty" xml:"title,omitempty" yaml:"title,omitempty"`
	Name         string    `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
	Email        string    `json:"email,omitempty" xml:"email,omitempty" yaml:"email,omitempty"`
	Created      time.Time `json:"created,omitempty" xml:"created,omitempty" yaml:"created,omitempty"`
	LastModified time.Time `json:"last_modified,omitempty" xml:"last_modified,omitempty" yaml:"last_modified,omitempty"`
	Revision     int       `json:"revision,omitempty" xml:"revision,omitempty" yaml:"revision,omitempty"`
	Avatar       string    `json:"avatar,omitempty" xml:"avatar,omitempty" yaml:"avatar,omitempty"`
}

UserMetadata is metadata associated with a user.

type UserMetadataBundle

type UserMetadataBundle struct {
	// contains filtered or unexported fields
}

UserMetadataBundle is a collection of public users.

func NewUserMetadataBundle

func NewUserMetadataBundle() *UserMetadataBundle

NewUserMetadataBundle returns an instance of UserMetadataBundle.

func (*UserMetadataBundle) Add

func (b *UserMetadataBundle) Add(k *UserMetadata)

Add adds UserMetadata to UserMetadataBundle.

func (*UserMetadataBundle) Get

func (b *UserMetadataBundle) Get() []*UserMetadata

Get returns UserMetadata instances of the UserMetadataBundle.

func (*UserMetadataBundle) Size

func (b *UserMetadataBundle) Size() int

Size returns the number of UserMetadata instances in UserMetadataBundle.

type UserPolicy

type UserPolicy struct {
	MinLength            int  `json:"min_length" xml:"min_length" yaml:"min_length"`
	MaxLength            int  `json:"max_length" xml:"max_length" yaml:"max_length"`
	AllowNonAlphaNumeric bool `json:"allow_non_alpha_numeric" xml:"allow_non_alpha_numeric" yaml:"allow_non_alpha_numeric"`
	AllowUppercase       bool `json:"allow_uppercase" xml:"allow_uppercase" yaml:"allow_uppercase"`
}

UserPolicy represents database username policy

type WebAuthnAuthenticateRequest

type WebAuthnAuthenticateRequest struct {
	ID                string      `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Type              string      `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
	AuthData          *AuthData   `json:"auth_data,omitempty" xml:"auth_data,omitempty" yaml:"auth_data,omitempty"`
	AuthDataEncoded   string      `json:"auth_data_encoded,omitempty" xml:"auth_data_encoded,omitempty" yaml:"auth_data_encoded,omitempty"`
	ClientData        *ClientData `json:"client_data,omitempty" xml:"client_data,omitempty" yaml:"client_data,omitempty"`
	ClientDataEncoded string      `json:"client_data_encoded,omitempty" xml:"client_data_encoded,omitempty" yaml:"client_data_encoded,omitempty"`
	Signature         string      `json:"signature,omitempty" xml:"signature,omitempty" yaml:"signature,omitempty"`
	SignatureEncoded  string      `json:"signature_encoded,omitempty" xml:"signature_encoded,omitempty" yaml:"signature_encoded,omitempty"`
	// contains filtered or unexported fields
}

WebAuthnAuthenticateRequest represents Webauthn Authentication request.

type WebAuthnRegisterRequest

type WebAuthnRegisterRequest struct {
	ID                string             `json:"id,omitempty" xml:"id,omitempty" yaml:"id,omitempty"`
	Type              string             `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
	Transports        []string           `json:"transports,omitempty" xml:"transports,omitempty" yaml:"transports,omitempty"`
	Success           bool               `json:"success,omitempty" xml:"success,omitempty" yaml:"success,omitempty"`
	AttestationObject *AttestationObject `json:"attestationObject,omitempty" xml:"attestationObject,omitempty" yaml:"attestationObject,omitempty"`
	ClientData        *ClientData        `json:"clientData,omitempty" xml:"clientData,omitempty" yaml:"clientData,omitempty"`
	Device            *Device            `json:"device,omitempty" xml:"device,omitempty" yaml:"device,omitempty"`
}

WebAuthnRegisterRequest is Webauthn Register request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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