Documentation ¶
Index ¶
- Constants
- Variables
- func GetShareToken(w http.ResponseWriter, r *http.Request)
- func ProcessUsers(w http.ResponseWriter, req *http.Request)
- func ValidateAuthMiddleware(next http.Handler, allowedRoles []string, checkXSRF bool) http.Handler
- func WhoAmI() http.Handler
- type ByID
- type DataHandler
- func (d *DataHandler) AddUser(w http.ResponseWriter, req *http.Request)
- func (d *DataHandler) DeleteUser(w http.ResponseWriter, req *http.Request)
- func (d *DataHandler) MatchUser(sentUser User) (User, error)
- func (d *DataHandler) SendUsers(w http.ResponseWriter, req *http.Request)
- func (d *DataHandler) UpdateUser(w http.ResponseWriter, req *http.Request)
- type Manager
- type TokenData
- type User
- type UserOAuth2
Constants ¶
const (
// ContextData is the user
ContextData key = 0
)
Variables ¶
var (
//UsersFile is the file containing the users
UsersFile = "./configs/users.json"
)
Functions ¶
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 ValidateAuthMiddleware ¶
ValidateAuthMiddleware validates that the token is valid and that the user has the correct roles
Types ¶
type DataHandler ¶
type DataHandler struct {
// contains filtered or unexported fields
}
DataHandler has the db connection
func NewDataHandler ¶
func NewDataHandler() *DataHandler
NewDataHandler init a DataHandler and returns a pointer to it
func (*DataHandler) AddUser ¶
func (d *DataHandler) AddUser(w http.ResponseWriter, req *http.Request)
AddUser adds an user
func (*DataHandler) DeleteUser ¶
func (d *DataHandler) DeleteUser(w http.ResponseWriter, req *http.Request)
DeleteUser remove an user
func (*DataHandler) MatchUser ¶
func (d *DataHandler) MatchUser(sentUser User) (User, error)
MatchUser attempt to find the given user against users in configuration file
func (*DataHandler) SendUsers ¶
func (d *DataHandler) SendUsers(w http.ResponseWriter, req *http.Request)
SendUsers send users as response from an http requests
func (*DataHandler) UpdateUser ¶
func (d *DataHandler) UpdateUser(w http.ResponseWriter, req *http.Request)
UpdateUser update an user
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 int `json:"id,omitempty"` IDOAuth string `json:"idOAuth,omitempry"` Login string `json:"login"` DisplayName string `json:"displayName,omitempty"` Role string `json:"role"` IsAdmin bool `json:"isAdmin,omitempty"` Name string `json:"name,omitempty"` Surname string `json:"surname,omitempty"` PasswordHash string `json:"-"` Password string `json:"password,omitempty"` }
User represents a logged in user
func GetLoggedUserTechnical ¶
func GetLoggedUserTechnical(w http.ResponseWriter, r *http.Request) User
GetLoggedUserTechnical return the User authenticated
type UserOAuth2 ¶
type UserOAuth2 struct { ID string `json:"id,omitempty"` Login string `json:"login"` DisplayName string `json:"displayName,omitempty"` Groups []string `json:"memberOf"` IsAdmin bool `json:"isAdmin,omitempty"` Name string `json:"name,omitempty"` Surname string `json:"surname,omitempty"` }
UserOAuth2 is the user get from OAuth2 authentification