userdetails

package
v0.0.0-...-85aee89 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	// 检测用户状态
	Check(user UserDetails) error
}

Checker 检查加载 UserDetails 的状态

type NilUserDetailsService

type NilUserDetailsService struct{}

func (*NilUserDetailsService) LoadUserByUsername

func (*NilUserDetailsService) LoadUserByUsername(username string) (UserDetails, error)

LoadUserByUsername 加载指定 username 的用户

type PostChecker

type PostChecker interface {
	Checker
	Post()
}

PostChecker 后置检查器

type PreChecker

type PreChecker interface {
	Checker
	Pre()
}

PreChecker 前置检查器

type Service

type Service interface {
	// 加载指定 username 的用户
	LoadUserByUsername(username string) (UserDetails, error)
}

Service �用于加载 UserDetails

type User

type User struct {
	Authorities           []core.GrantedAuthority
	Username              string
	Password              string
	AccountNonExpired     bool
	AccountNonLocked      bool
	CredentialsNonExpired bool
	Enabled               bool
}

User UserDetails 的基本实现

func NewUser

func NewUser(username, password string, authorities []core.GrantedAuthority) *User

NewUser 实例化

func NewUserAllParams

func NewUserAllParams(username, password string, authorities []core.GrantedAuthority, accountNonExpired, accountNonLocked, credentialsNonExpired, enabled bool) *User

NewUserAllParams 实例化

func (*User) GetAuthorities

func (u *User) GetAuthorities() []core.GrantedAuthority

GetAuthorities 获取授予用户的权限

func (*User) GetPassword

func (u *User) GetPassword() string

GetPassword 获取密码

func (*User) GetUsername

func (u *User) GetUsername() string

GetUsername 获取用户名

func (*User) IsAccountNonExpired

func (u *User) IsAccountNonExpired() bool

IsAccountNonExpired 账户是否未过期

func (*User) IsAccountNonLocked

func (u *User) IsAccountNonLocked() bool

IsAccountNonLocked 账户是否未锁定

func (*User) IsCredentialsNonExpired

func (u *User) IsCredentialsNonExpired() bool

IsCredentialsNonExpired 用户凭证(密码)是否未过期

func (*User) IsEnabled

func (u *User) IsEnabled() bool

IsEnabled 用户是否可用

type UserCache

type UserCache interface {
	// 从缓存中获取用户信息
	GetUserFromCache(string) (UserDetails, error)
	// 增加缓存
	PutUserInCache(UserDetails) error
	// 移除缓存
	RemoveUserFromCache(string) error
}

UserCache 用户缓存接口

type UserDetails

type UserDetails interface {
	// 获取授予用户的权限
	GetAuthorities() []core.GrantedAuthority
	// 获取用户名
	GetUsername() string
	// 获取密码
	GetPassword() string
	// 账户是否未过期
	IsAccountNonExpired() bool
	// 账户是否未锁定
	IsAccountNonLocked() bool
	// 用户凭证(密码)是否未过期
	IsCredentialsNonExpired() bool
	// 用户是否可用
	IsEnabled() bool
}

UserDetails 用户信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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