Documentation
¶
Index ¶
- Variables
- func Authorize(p Principal, op Operation, ownerKeyID string) error
- func ClearSessionCookie(allowInsecureHTTP bool) *http.Cookie
- func SessionCookie(value string, allowInsecureHTTP bool) *http.Cookie
- type Key
- type Level
- type LoginPolicy
- type Operation
- type Principal
- type Service
- func (s Service) Authenticate(ctx context.Context, bearer string) (Principal, error)
- func (s Service) BootstrapUser(ctx context.Context, login, password string) (string, error)
- func (s Service) ChangePassword(ctx context.Context, p Principal, oldPassword, newPassword string) error
- func (s Service) IssueKey(ctx context.Context, p Principal, name string, level Level, expires *time.Time, ...) (Key, string, error)
- func (s Service) Keys(ctx context.Context, p Principal) ([]Key, error)
- func (s Service) Login(ctx context.Context, login, password string) (session, csrf string, p Principal, err error)
- func (s Service) LoginWithIP(ctx context.Context, login, password, ip string) (session, csrf string, p Principal, err error)
- func (s Service) Logout(ctx context.Context, session string) error
- func (s Service) LogoutAll(ctx context.Context, p Principal) error
- func (s Service) ResetPassword(ctx context.Context, login, newPassword string) error
- func (s Service) Revoke(ctx context.Context, p Principal, id string) error
- func (s Service) Session(ctx context.Context, session, csrf string, mutating bool) (Principal, error)
- func (s Service) SetLevel(ctx context.Context, p Principal, id string, level Level) error
- func (s Service) UpdateKey(ctx context.Context, p Principal, id, name, note string, expires *time.Time) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrForbidden = errors.New("forbidden")
View Source
var ErrInvalid = errors.New("invalid input")
Functions ¶
func ClearSessionCookie ¶
Types ¶
type Key ¶
type Key struct {
ID string `json:"id"`
Name string `json:"name"`
IssuerID string `json:"issuer_id"`
IssuerName string `json:"issuer_name"`
CreatedAt string `json:"created_at"`
ExpiresAt string `json:"expires_at"`
Note string `json:"note"`
LastUsedAt string `json:"last_used_at"`
RevokedAt string `json:"revoked_at"`
Level Level `json:"level"`
}
type LoginPolicy ¶ added in v0.3.0
LoginPolicy 控制账号和客户端 IP 的限速;零值使用默认配置。
type Operation ¶
type Operation string
const ( View Operation = "view" PutContext Operation = "put_context" RecordNote Operation = "record_note" ProposeChange Operation = "propose_change" Update Operation = "update" MarkVerified Operation = "mark_verified" CheckVersions Operation = "check_versions" Approve Operation = "approve" Reject Operation = "reject" Delete Operation = "delete" ManageKeys Operation = "manage_keys" Restore Operation = "restore" )
type Service ¶
type Service struct {
DB *sql.DB
Pepper []byte
LoginPolicy LoginPolicy
}
func (Service) Authenticate ¶
func (Service) BootstrapUser ¶
BootstrapUser is for a local, one-time setup command; it refuses a second account.
func (Service) ChangePassword ¶ added in v0.3.0
func (Service) LoginWithIP ¶ added in v0.3.0
func (s Service) LoginWithIP(ctx context.Context, login, password, ip string) (session, csrf string, p Principal, err error)
LoginWithIP 使用 HTTP 层提供的连接对端 IP;调用方不得传入未验证的代理头。
func (Service) ResetPassword ¶ added in v0.3.0
func (Service) Session ¶
func (s Service) Session(ctx context.Context, session, csrf string, mutating bool) (Principal, error)
Session verifies the cookie and, for mutating methods, the double-submit CSRF token.
Click to show internal directories.
Click to hide internal directories.