auth

package
v5.0.0-beta.16 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package auth is a generated GoMock package.

Index

Constants

View Source
const Expired = 8 * time.Hour

Variables

View Source
var WireAuth = wire.NewSet(NewAuthn)

Functions

func SetUser

func SetUser(ctx context.Context, info *UserInfo) context.Context

Types

type Auth

type Auth interface {
	Authenticator
	Sign(*UserInfo) (*SignData, error)
}

func NewAuthn

func NewAuthn(data data.Data) (Auth, error)

func NewJwtAuth

func NewJwtAuth(priKey *rsa.PrivateKey, pubKey *rsa.PublicKey) Auth

type Authenticator

type Authenticator interface {
	VerifyToken(string) (*JwtClaims, bool)
}

func NewAccessTokenAuth

func NewAccessTokenAuth(data data.Data) Authenticator

type Authn

type Authn struct {
	Authns []Authenticator
	// contains filtered or unexported fields
}

func (*Authn) Sign

func (a *Authn) Sign(info *UserInfo) (*SignData, error)

func (*Authn) VerifyToken

func (a *Authn) VerifyToken(s string) (*JwtClaims, bool)

type JwtClaims

type JwtClaims struct {
	*jwt.StandardClaims
	UserInfo *UserInfo `json:"user_info"`
}

type MockAuth

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

MockAuth is a mock of Auth interface.

func NewMockAuth

func NewMockAuth(ctrl *gomock.Controller) *MockAuth

NewMockAuth creates a new mock instance.

func (*MockAuth) EXPECT

func (m *MockAuth) EXPECT() *MockAuthMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAuth) Sign

func (m *MockAuth) Sign(arg0 *schematype.UserInfo) (*SignData, error)

Sign mocks base method.

func (*MockAuth) VerifyToken

func (m *MockAuth) VerifyToken(arg0 string) (*JwtClaims, bool)

VerifyToken mocks base method.

type MockAuthMockRecorder

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

MockAuthMockRecorder is the mock recorder for MockAuth.

func (*MockAuthMockRecorder) Sign

func (mr *MockAuthMockRecorder) Sign(arg0 any) *gomock.Call

Sign indicates an expected call of Sign.

func (*MockAuthMockRecorder) VerifyToken

func (mr *MockAuthMockRecorder) VerifyToken(arg0 any) *gomock.Call

VerifyToken indicates an expected call of VerifyToken.

type OidcClaims

type OidcClaims struct {
	LogoutUrl string `json:"logout_url"`
	OpenIDClaims
}

func (OidcClaims) ToUserInfo

func (c OidcClaims) ToUserInfo() *UserInfo

type OpenIDClaims

type OpenIDClaims struct {
	Sub                 string         `json:"sub"`
	Name                string         `json:"name"`
	GivenName           string         `json:"given_name"`
	FamilyName          string         `json:"family_name"`
	MiddleName          string         `json:"middle_name"`
	Nickname            string         `json:"nickname"`
	PreferredUsername   string         `json:"preferred_username"`
	Profile             string         `json:"profile"`
	Picture             string         `json:"picture"`
	Website             string         `json:"website"`
	Email               string         `json:"email"`
	EmailVerified       bool           `json:"email_verified"`
	Gender              string         `json:"gender"`
	Birthdate           string         `json:"birthdate"`
	Zoneinfo            string         `json:"zoneinfo"`
	Locale              string         `json:"locale"`
	PhoneNumber         string         `json:"phone_number"`
	PhoneNumberVerified bool           `json:"phone_number_verified"`
	Address             map[string]any `json:"address"`
	UpdatedAt           int            `json:"updated_at"`

	// Roles 自定义权限
	Roles []string `json:"roles"`
}

type SignData

type SignData struct {
	Token     string
	ExpiredIn int64
}

type UserInfo

type UserInfo = schematype.UserInfo

func GetUser

func GetUser(ctx context.Context) (*UserInfo, error)

func MustGetUser

func MustGetUser(ctx context.Context) *UserInfo

Jump to

Keyboard shortcuts

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