Documentation ¶
Index ¶
- Constants
- type Credential
- type CredentialsStore
- func (c *CredentialsStore) Check(username, password string) bool
- func (c *CredentialsStore) CheckRequest(b IBasicAuth) bool
- func (c *CredentialsStore) HasAnyPerm(username string, perm ...string) bool
- func (c *CredentialsStore) HasPerm(username string, perm string) bool
- func (c *CredentialsStore) HasPermRequest(b IBasicAuth, perm string) bool
- func (c *CredentialsStore) Load(r io.Reader) error
- func (c *CredentialsStore) Password(username string) (string, bool)
- type IBasicAuth
Constants ¶
const AllUsers = "*"
AllUsers is the username that indicates all users, even anonymous users (requests without any BasicAuth information).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credential ¶
type Credential struct { Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` Perms []string `json:"perms,omitempty"` }
Credential represents authentication and authorization configuration for a single user.
type CredentialsStore ¶
type CredentialsStore struct {
// contains filtered or unexported fields
}
CredentialsStore stores authentication and authorization information for all users.
func NewCredentialsStore ¶
func NewCredentialsStore() *CredentialsStore
NewCredentialsStore returns a new instance of a CredentialStore.
func (*CredentialsStore) Check ¶
func (c *CredentialsStore) Check(username, password string) bool
Check returns true if the password is correct for the given username.
func (*CredentialsStore) CheckRequest ¶
func (c *CredentialsStore) CheckRequest(b IBasicAuth) bool
CheckRequest returns true if b contains a valid username and password.
func (*CredentialsStore) HasAnyPerm ¶
func (c *CredentialsStore) HasAnyPerm(username string, perm ...string) bool
HasAnyPerm returns true if username has at least one of the given perms, either directly, or via AllUsers. It does not perform any password checking.
func (*CredentialsStore) HasPerm ¶
func (c *CredentialsStore) HasPerm(username string, perm string) bool
HasPerm returns true if username has the given perm, either directly or via AllUsers. It does not perform any password checking.
func (*CredentialsStore) HasPermRequest ¶
func (c *CredentialsStore) HasPermRequest(b IBasicAuth, perm string) bool
HasPermRequest returns true if the username returned by b has the givem perm. It does not perform any password checking, but if there is no username in the request, it returns false.
type IBasicAuth ¶
IBasicAuth is the interface an object must support to return basic auth information.