Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth interface { // Create and return a new token that allows access to each API endpoint for // [duration] such that the API's path ends with an element of [endpoints]. // If one of the elements of [endpoints] is "*", all APIs are accessible. NewToken(pw string, duration time.Duration, endpoints []string) (string, error) // Revokes [token]; it will not be accepted as authorization for future API // calls. If the token is invalid, this is a no-op. If a token is revoked // and then the password is changed, and then changed back to the current // password, the token will be un-revoked. Therefore, passwords shouldn't be // re-used before previously revoked tokens have expired. RevokeToken(pw, token string) error // Authenticates [token] for access to [url]. AuthenticateToken(token, url string) error // Change the password required to create and revoke tokens. // [oldPW] is the current password. // [newPW] is the new password. It can't be the empty string and it can't be // unreasonably long. // Changing the password makes tokens issued under a previous password // invalid. ChangePassword(oldPW, newPW string) error // Create the API endpoint for this auth handler. CreateHandler() (http.Handler, error) // WrapHandler wraps an http.Handler. Before passing a request to the // provided handler, the auth token is authenticated. WrapHandler(h http.Handler) http.Handler }
type ChangePasswordArgs ¶
type NewTokenArgs ¶
type NewTokenArgs struct { Password // Endpoints that may be accessed with this token e.g. if endpoints is // ["/ext/bc/A", "/ext/admin"] then the token holder can hit the A-Chain API // and the admin API. If [Endpoints] contains an element "*" then the token // allows access to all API endpoints. [Endpoints] must have between 1 and // [maxEndpoints] elements Endpoints []string `json:"endpoints"` }
type Password ¶
type Password struct {
Password string `json:"password"` // The authorization password
}
type RevokeTokenArgs ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service that serves the Auth API functionality.
func (*Service) ChangePassword ¶
func (s *Service) ChangePassword(_ *http.Request, args *ChangePasswordArgs, _ *api.EmptyReply) error
func (*Service) RevokeToken ¶
func (s *Service) RevokeToken(_ *http.Request, args *RevokeTokenArgs, _ *api.EmptyReply) error
Click to show internal directories.
Click to hide internal directories.