Documentation
¶
Index ¶
- Variables
- func RedirectToRequested(loginURL string) func(w http.ResponseWriter, r *http.Request, requested string)
- func RequireLoggedIn(provider AuthorizationProvider, next http.Handler) http.Handler
- func RequireRole(roles []string, provider AuthorizationProvider, next http.Handler) http.Handler
- type AuthorizationProvider
- type Identity
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// ReturnURL is the query parameter used to specify the url to return to once the user is logged in.
ReturnURL = "ret"
)
Functions ¶
func RedirectToRequested ¶
func RedirectToRequested(loginURL string) func(w http.ResponseWriter, r *http.Request, requested string)
RedirectToRequested returns a handler to redirect to a login url and preserve the originially requested url as a get parameter.
func RequireLoggedIn ¶
func RequireLoggedIn(provider AuthorizationProvider, next http.Handler) http.Handler
RequireLoggedIn requires the user to be logged in to access this page.
func RequireRole ¶
RequireRole requires the user to have one of the specified roles.
Types ¶
type AuthorizationProvider ¶
type AuthorizationProvider interface { // SetIdentity sets the role of the user. SetIdentity(w http.ResponseWriter, identity Identity) error // GetIdentity return the users roll, or an error if the user has no role. GetIdentity(r *http.Request) (Identity, error) // RemoveIdentity removes the role from the user. RemoveIdentity(w http.ResponseWriter) error // Handles when a user needs to be shown an error page for not being in the correct role. HandleInvalidRole(w http.ResponseWriter, r *http.Request) // Handles when a user needs to login. HandleLogin(w http.ResponseWriter, r *http.Request, redirect string) }
AuthorizationProvider is the interface that describes the authorization mechanisms.
Click to show internal directories.
Click to hide internal directories.