Documentation
¶
Index ¶
- Constants
- Variables
- func AddUser(w http.ResponseWriter, req *http.Request)
- func DeleteUser(w http.ResponseWriter, req *http.Request)
- func GetShareToken(w http.ResponseWriter, r *http.Request)
- func ProcessUsers(w http.ResponseWriter, req *http.Request)
- func SendUsers(w http.ResponseWriter, req *http.Request)
- func ValidateAuthMiddleware(next http.Handler, allowedRoles []string, checkXSRF bool) http.Handler
- func WhoAmI() http.Handler
- type ByID
- type Manager
- type TokenData
- type User
Constants ¶
const (
// ContextData is the user
ContextData key = 0
)
Variables ¶
var (
//UsersFile is the file containing the users
UsersFile = "./configs/users.json"
)
Functions ¶
func DeleteUser ¶
func DeleteUser(w http.ResponseWriter, req *http.Request)
DeleteUser deletes an user
func GetShareToken ¶
func GetShareToken(w http.ResponseWriter, r *http.Request)
GetShareToken gets a share token for a given ressource
func ProcessUsers ¶
func ProcessUsers(w http.ResponseWriter, req *http.Request)
ProcessUsers processes users regarding of HTTP method
func SendUsers ¶
func SendUsers(w http.ResponseWriter, req *http.Request)
SendUsers send users as response from an http requests
func ValidateAuthMiddleware ¶
ValidateAuthMiddleware validates that the token is valid and that the user has the correct roles
Types ¶
type Manager ¶
Manager exposes the handlers for OAuth2 endpoints
func NewManager ¶
func NewManager() Manager
NewManager returns a new Manager according to environment variables
func (Manager) HandleInMemoryLogin ¶
func (m Manager) HandleInMemoryLogin(w http.ResponseWriter, r *http.Request)
HandleInMemoryLogin validate the username and password provided in the function body against a local file and return a token if the user is found
func (Manager) HandleLogout ¶
func (m Manager) HandleLogout(w http.ResponseWriter, r *http.Request)
HandleLogout remove the user from the cookie store
func (Manager) HandleOAuth2Callback ¶
HandleOAuth2Callback handles the OAuth2 Callback and get user info
func (Manager) HandleOAuth2Login ¶
func (m Manager) HandleOAuth2Login(w http.ResponseWriter, r *http.Request)
HandleOAuth2Login handles the OAuth2 login
type TokenData ¶
type TokenData struct {
User
URL string `json:"url,omitempty"`
ReadOnly bool `json:"readonly,omitempty"`
SharingUserLogin string `json:"sharinguserlogin,omitempty"`
XSRFToken string `json:"xsrftoken,omitempty"`
}
TokenData represents the data held into a token
type User ¶
type User struct {
ID string `json:"id,omitempty"`
Login string `json:"login"`
DisplayName string `json:"displayName,omitempty"`
Email string `json:"email,omitempty"`
Roles []string `json:"memberOf"`
IsAdmin bool `json:"isAdmin,omitempty"`
Name string `json:"name,omitempty"`
Surname string `json:"surname,omitempty"`
PasswordHash string `json:"passwordHash,omitempty"`
Password string `json:"password,omitempty"`
}
User represents a logged in user