Documentation ¶
Overview ¶
Package auth provides authentication and authorization for RPCs.
Package auth provides the authentication and authorization of the admin server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnauthenticated is returned when the authentication is failed. ErrUnauthenticated = errors.New("unauthenticated") // ErrPermissionDenied is returned when the given user is not allowed for the access. ErrPermissionDenied = errors.New("method is not allowed for this user") // ErrUnexpectedStatusCode is returned when the response code is not 200 from the webhook. ErrUnexpectedStatusCode = errors.New("unexpected status code from webhook") // ErrUnexpectedResponse is returned when the response from the webhook is not as expected. ErrUnexpectedResponse = errors.New("unexpected response from webhook") // ErrWebhookTimeout is returned when the webhook does not respond in time. ErrWebhookTimeout = errors.New("webhook timeout") )
View Source
var ( // ErrUnexpectedSigningMethod is returned when the signing method is unexpected. ErrUnexpectedSigningMethod = fmt.Errorf("unexpected signing method") )
Functions ¶
func AccessAttributes ¶
func AccessAttributes(pack *change.Pack) []types.AccessAttribute
AccessAttributes returns an array of AccessAttribute from the given pack.
func VerifyAccess ¶
VerifyAccess verifies the given access.
Types ¶
type TokenManager ¶ added in v0.3.5
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager manages JWT tokens.
func NewTokenManager ¶ added in v0.3.5
func NewTokenManager(secretKey string, tokenDuration time.Duration) *TokenManager
NewTokenManager creates a new TokenManager.
func (*TokenManager) Generate ¶ added in v0.3.5
func (m *TokenManager) Generate(username string) (string, error)
Generate generates a new token for the user.
func (*TokenManager) Verify ¶ added in v0.3.5
func (m *TokenManager) Verify(token string) (*UserClaims, error)
Verify verifies the given token.
type UserClaims ¶ added in v0.3.5
type UserClaims struct { jwt.StandardClaims Username string `json:"username"` }
UserClaims is a JWT claims struct for a user.
Click to show internal directories.
Click to hide internal directories.