12345678910111213141516171819202122232425262728293031323334 |
- package auth
- import (
- "net/http"
- )
- type AuthData struct {
- User string
- Group string
- Properties map[string]string
- }
- type AuthManager interface {
- AddUser(user string, group string, password string) error
- DeleteUser(user string) error
- DoAuth(w http.ResponseWriter, r *http.Request) (*AuthData, bool)
- }
- type Authenticator interface {
- DoAuth(w http.ResponseWriter, r *http.Request) (*AuthData, bool)
- }
- func NewAuth(kind string) AuthManager {
- switch kind {
- case "basic":
- return NewBasicAuth()
- case "token":
- return NewTokenAuth()
- default:
- return NewNoAuth()
- }
- }
|