Versions in this module Expand all Collapse all v0 v0.19.4 May 24, 2023 Changes in this version + var Names = map[Type]string + func AccessTokenByNameExists(token *AccessToken) (bool, error) + func CleanupSessions(maxLifetime int64) error + func CountAccessTokens(opts ListAccessTokensOptions) (int64, error) + func CountSessions() (int64, error) + func CountSources() int64 + func CreateSource(source *Source) error + func DeleteAccessTokenByID(id, userID int64) error + func DeleteCredential(id, userID int64) (bool, error) + func DeleteOAuth2Application(id, userid int64) error + func DeleteOAuth2RelictsByUserID(ctx context.Context, userID int64) error + func DeleteTwoFactorByID(id, userID int64) error + func DestroySession(key string) error + func ExistSession(key string) (bool, error) + func ExistsWebAuthnCredentialsForUID(uid int64) (bool, error) + func HasTwoFactorByUID(uid int64) (bool, error) + func HasWebAuthnRegistrationsByUID(uid int64) (bool, error) + func HashToken(token, salt string) string + func IsErrAccessTokenEmpty(err error) bool + func IsErrAccessTokenNotExist(err error) bool + func IsErrOAuthApplicationNotFound(err error) bool + func IsErrOauthClientIDInvalid(err error) bool + func IsErrSourceAlreadyExist(err error) bool + func IsErrSourceInUse(err error) bool + func IsErrSourceNotExist(err error) bool + func IsErrTwoFactorNotEnrolled(err error) bool + func IsErrWebAuthnCredentialNotExist(err error) bool + func IsSSPIEnabled() bool + func NewAccessToken(t *AccessToken) error + func NewTwoFactor(t *TwoFactor) error + func RegisterTypeConfig(typ Type, exemplar Config) + func RevokeOAuth2Grant(ctx context.Context, grantID, userID int64) error + func UpdateAccessToken(t *AccessToken) error + func UpdateSession(key string, data []byte) error + func UpdateSource(source *Source) error + func UpdateTwoFactor(t *TwoFactor) error + func WebAuthnCredentials(userID int64) ([]webauthn.Credential, error) + type AccessToken struct + CreatedUnix timeutil.TimeStamp + HasRecentActivity bool + HasUsed bool + ID int64 + Name string + Scope AccessTokenScope + Token string + TokenHash string + TokenLastEight string + TokenSalt string + UID int64 + UpdatedUnix timeutil.TimeStamp + func GetAccessTokenBySHA(token string) (*AccessToken, error) + func ListAccessTokens(opts ListAccessTokensOptions) ([]*AccessToken, error) + func (t *AccessToken) AfterLoad() + type AccessTokenScope string + const AccessTokenScopeAdminApplication + const AccessTokenScopeAdminGPGKey + const AccessTokenScopeAdminOrg + const AccessTokenScopeAdminOrgHook + const AccessTokenScopeAdminPublicKey + const AccessTokenScopeAdminRepoHook + const AccessTokenScopeAdminUserHook + const AccessTokenScopeAll + const AccessTokenScopeDeletePackage + const AccessTokenScopeDeleteRepo + const AccessTokenScopeNotification + const AccessTokenScopePackage + const AccessTokenScopePublicRepo + const AccessTokenScopeReadApplication + const AccessTokenScopeReadGPGKey + const AccessTokenScopeReadOrg + const AccessTokenScopeReadPackage + const AccessTokenScopeReadPublicKey + const AccessTokenScopeReadRepoHook + const AccessTokenScopeReadUser + const AccessTokenScopeRepo + const AccessTokenScopeRepoStatus + const AccessTokenScopeSudo + const AccessTokenScopeUser + const AccessTokenScopeUserEmail + const AccessTokenScopeUserFollow + const AccessTokenScopeWriteApplication + const AccessTokenScopeWriteGPGKey + const AccessTokenScopeWriteOrg + const AccessTokenScopeWritePackage + const AccessTokenScopeWritePublicKey + const AccessTokenScopeWriteRepoHook + func (s AccessTokenScope) HasScope(scope AccessTokenScope) (bool, error) + func (s AccessTokenScope) Normalize() (AccessTokenScope, error) + func (s AccessTokenScope) Parse() (AccessTokenScopeBitmap, error) + func (s AccessTokenScope) StringSlice() []string + type AccessTokenScopeBitmap uint64 + const AccessTokenScopeAdminApplicationBits + const AccessTokenScopeAdminGPGKeyBits + const AccessTokenScopeAdminOrgBits + const AccessTokenScopeAdminOrgHookBits + const AccessTokenScopeAdminPublicKeyBits + const AccessTokenScopeAdminRepoHookBits + const AccessTokenScopeAdminUserHookBits + const AccessTokenScopeAllBits + const AccessTokenScopeDeletePackageBits + const AccessTokenScopeDeleteRepoBits + const AccessTokenScopeNotificationBits + const AccessTokenScopePackageBits + const AccessTokenScopePublicRepoBits + const AccessTokenScopeReadApplicationBits + const AccessTokenScopeReadGPGKeyBits + const AccessTokenScopeReadOrgBits + const AccessTokenScopeReadPackageBits + const AccessTokenScopeReadPublicKeyBits + const AccessTokenScopeReadRepoHookBits + const AccessTokenScopeReadUserBits + const AccessTokenScopeRepoBits + const AccessTokenScopeRepoStatusBits + const AccessTokenScopeSudoBits + const AccessTokenScopeUserBits + const AccessTokenScopeUserEmailBits + const AccessTokenScopeUserFollowBits + const AccessTokenScopeWriteApplicationBits + const AccessTokenScopeWriteGPGKeyBits + const AccessTokenScopeWriteOrgBits + const AccessTokenScopeWritePackageBits + const AccessTokenScopeWritePublicKeyBits + const AccessTokenScopeWriteRepoHookBits + func (bitmap AccessTokenScopeBitmap) HasScope(scope AccessTokenScope) (bool, error) + func (bitmap AccessTokenScopeBitmap) ToScope() AccessTokenScope + type Config interface + type CreateOAuth2ApplicationOptions struct + ConfidentialClient bool + Name string + RedirectURIs []string + UserID int64 + type ErrAccessTokenEmpty struct + func (err ErrAccessTokenEmpty) Error() string + func (err ErrAccessTokenEmpty) Unwrap() error + type ErrAccessTokenNotExist struct + Token string + func (err ErrAccessTokenNotExist) Error() string + func (err ErrAccessTokenNotExist) Unwrap() error + type ErrOAuthApplicationNotFound struct + ID int64 + func (err ErrOAuthApplicationNotFound) Error() string + func (err ErrOAuthApplicationNotFound) Unwrap() error + type ErrOAuthClientIDInvalid struct + ClientID string + func (err ErrOAuthClientIDInvalid) Error() string + func (err ErrOAuthClientIDInvalid) Unwrap() error + type ErrSourceAlreadyExist struct + Name string + func (err ErrSourceAlreadyExist) Error() string + func (err ErrSourceAlreadyExist) Unwrap() error + type ErrSourceInUse struct + ID int64 + func (err ErrSourceInUse) Error() string + type ErrSourceNotExist struct + ID int64 + func (err ErrSourceNotExist) Error() string + func (err ErrSourceNotExist) Unwrap() error + type ErrTwoFactorNotEnrolled struct + UID int64 + func (err ErrTwoFactorNotEnrolled) Error() string + func (err ErrTwoFactorNotEnrolled) Unwrap() error + type ErrWebAuthnCredentialNotExist struct + CredentialID []byte + ID int64 + func (err ErrWebAuthnCredentialNotExist) Error() string + func (err ErrWebAuthnCredentialNotExist) Unwrap() error + type HasTLSer interface + HasTLS func() bool + type ListAccessTokensOptions struct + Name string + UserID int64 + type OAuth2Application struct + ClientID string + ClientSecret string + ConfidentialClient bool + CreatedUnix timeutil.TimeStamp + ID int64 + Name string + RedirectURIs []string + UID int64 + UpdatedUnix timeutil.TimeStamp + func CreateOAuth2Application(ctx context.Context, opts CreateOAuth2ApplicationOptions) (*OAuth2Application, error) + func GetOAuth2ApplicationByClientID(ctx context.Context, clientID string) (app *OAuth2Application, err error) + func GetOAuth2ApplicationByID(ctx context.Context, id int64) (app *OAuth2Application, err error) + func GetOAuth2ApplicationsByUserID(ctx context.Context, userID int64) (apps []*OAuth2Application, err error) + func ListOAuth2Applications(uid int64, listOptions db.ListOptions) ([]*OAuth2Application, int64, error) + func UpdateOAuth2Application(opts UpdateOAuth2ApplicationOptions) (*OAuth2Application, error) + func (app *OAuth2Application) ContainsRedirectURI(redirectURI string) bool + func (app *OAuth2Application) CreateGrant(ctx context.Context, userID int64, scope string) (*OAuth2Grant, error) + func (app *OAuth2Application) GenerateClientSecret() (string, error) + func (app *OAuth2Application) GetGrantByUserID(ctx context.Context, userID int64) (grant *OAuth2Grant, err error) + func (app *OAuth2Application) PrimaryRedirectURI() string + func (app *OAuth2Application) TableName() string + func (app *OAuth2Application) ValidateClientSecret(secret []byte) bool + type OAuth2AuthorizationCode struct + Code string + CodeChallenge string + CodeChallengeMethod string + Grant *OAuth2Grant + GrantID int64 + ID int64 + RedirectURI string + ValidUntil timeutil.TimeStamp + func GetOAuth2AuthorizationByCode(ctx context.Context, code string) (auth *OAuth2AuthorizationCode, err error) + func (code *OAuth2AuthorizationCode) GenerateRedirectURI(state string) (redirect *url.URL, err error) + func (code *OAuth2AuthorizationCode) Invalidate(ctx context.Context) error + func (code *OAuth2AuthorizationCode) TableName() string + func (code *OAuth2AuthorizationCode) ValidateCodeChallenge(verifier string) bool + type OAuth2Grant struct + Application *OAuth2Application + ApplicationID int64 + Counter int64 + CreatedUnix timeutil.TimeStamp + ID int64 + Nonce string + Scope string + UpdatedUnix timeutil.TimeStamp + UserID int64 + func GetOAuth2GrantByID(ctx context.Context, id int64) (grant *OAuth2Grant, err error) + func GetOAuth2GrantsByUserID(ctx context.Context, uid int64) ([]*OAuth2Grant, error) + func (grant *OAuth2Grant) GenerateNewAuthorizationCode(ctx context.Context, redirectURI, codeChallenge, codeChallengeMethod string) (code *OAuth2AuthorizationCode, err error) + func (grant *OAuth2Grant) IncreaseCounter(ctx context.Context) error + func (grant *OAuth2Grant) ScopeContains(scope string) bool + func (grant *OAuth2Grant) SetNonce(ctx context.Context, nonce string) error + func (grant *OAuth2Grant) TableName() string + type RegisterableSource interface + RegisterSource func() error + UnregisterSource func() error + type SSHKeyProvider interface + ProvidesSSHKeys func() bool + type Session struct + Data []byte + Expiry timeutil.TimeStamp + Key string + func ReadSession(key string) (*Session, error) + func RegenerateSession(oldKey, newKey string) (*Session, error) + type SkipVerifiable interface + IsSkipVerify func() bool + type Source struct + Cfg convert.Conversion + CreatedUnix timeutil.TimeStamp + ID int64 + IsActive bool + IsSyncEnabled bool + Name string + Type Type + UpdatedUnix timeutil.TimeStamp + func ActiveSources(tp Type) ([]*Source, error) + func AllActiveSources() ([]*Source, error) + func GetActiveOAuth2ProviderSources() ([]*Source, error) + func GetActiveOAuth2SourceByName(name string) (*Source, error) + func GetSourceByID(id int64) (*Source, error) + func Sources() ([]*Source, error) + func SourcesByType(loginType Type) ([]*Source, error) + func (Source) TableName() string + func (source *Source) BeforeSet(colName string, val xorm.Cell) + func (source *Source) HasTLS() bool + func (source *Source) IsDLDAP() bool + func (source *Source) IsLDAP() bool + func (source *Source) IsOAuth2() bool + func (source *Source) IsPAM() bool + func (source *Source) IsSMTP() bool + func (source *Source) IsSSPI() bool + func (source *Source) SkipVerify() bool + func (source *Source) TypeName() string + func (source *Source) UseTLS() bool + type SourceSettable interface + SetAuthSource func(*Source) + type TwoFactor struct + CreatedUnix timeutil.TimeStamp + ID int64 + LastUsedPasscode string + ScratchHash string + ScratchSalt string + Secret string + UID int64 + UpdatedUnix timeutil.TimeStamp + func GetTwoFactorByUID(uid int64) (*TwoFactor, error) + func (t *TwoFactor) GenerateScratchToken() (string, error) + func (t *TwoFactor) SetSecret(secretString string) error + func (t *TwoFactor) ValidateTOTP(passcode string) (bool, error) + func (t *TwoFactor) VerifyScratchToken(token string) bool + type Type int + const DLDAP + const LDAP + const NoType + const OAuth2 + const PAM + const Plain + const SMTP + const SSPI + func (typ Type) Int() int + func (typ Type) String() string + type UpdateOAuth2ApplicationOptions struct + ConfidentialClient bool + ID int64 + Name string + RedirectURIs []string + UserID int64 + type UseTLSer interface + UseTLS func() bool + type WebAuthnCredential struct + AAGUID []byte + AttestationType string + CloneWarning bool + CreatedUnix timeutil.TimeStamp + CredentialID []byte + ID int64 + LowerName string + Name string + PublicKey []byte + SignCount uint32 + UpdatedUnix timeutil.TimeStamp + UserID int64 + func CreateCredential(userID int64, name string, cred *webauthn.Credential) (*WebAuthnCredential, error) + func GetWebAuthnCredentialByCredID(userID int64, credID []byte) (*WebAuthnCredential, error) + func GetWebAuthnCredentialByID(id int64) (*WebAuthnCredential, error) + func GetWebAuthnCredentialByName(uid int64, name string) (*WebAuthnCredential, error) + func (cred *WebAuthnCredential) AfterLoad(session *xorm.Session) + func (cred *WebAuthnCredential) BeforeInsert() + func (cred *WebAuthnCredential) BeforeUpdate() + func (cred *WebAuthnCredential) UpdateSignCount() error + func (cred WebAuthnCredential) TableName() string + type WebAuthnCredentialList []*WebAuthnCredential + func GetWebAuthnCredentialsByUID(uid int64) (WebAuthnCredentialList, error) + func (list WebAuthnCredentialList) ToCredentials() []webauthn.Credential