Documentation ¶
Overview ¶
Package idputil contains utility routines common to many identity providers.
Index ¶
- Constants
- Variables
- func BadRequestf(w http.ResponseWriter, f string, args ...interface{})
- func DischargeID(req *http.Request) string
- func GetLoginMethods(ctx context.Context, c *httprequest.Client, u *url.URL, v interface{}) error
- func HandleLoginForm(ctx context.Context, w http.ResponseWriter, req *http.Request, ...) (*store.Identity, error)
- func NameWithDomain(name, domain string) string
- func RedirectURL(prefix, path, state string) string
- func RegistrationForm(ctx context.Context, w http.ResponseWriter, params RegistrationParams, ...) error
- func RequestParams(ctx context.Context, w http.ResponseWriter, req *http.Request) httprequest.Params
- func ServiceURL(location, dest string) string
- func State(req *http.Request) string
- func URL(prefix, path, dischargeID string) string
- type LoginFormParams
- type LoginState
- type RegistrationParams
Constants ¶
const LoginCookieName = "candid-login"
LoginCookieName is the name of the cookie used to store LoginState whilst a login is being processed.
Variables ¶
var ReservedUsernames = map[string]bool{ "admin": true, "everyone": true, }
Functions ¶
func BadRequestf ¶
func BadRequestf(w http.ResponseWriter, f string, args ...interface{})
BadRequestf writes the given bad request message to the given ResponseWriter. It should be used by IDPs when they do not have enough state to pass the error message along to the initiating page.
func DischargeID ¶
DischargeID gets the discharge ID from the given request using the standard form value.
func GetLoginMethods ¶
GetLoginMethods uses c to perform a request to get the list of available login methods from u. The result is unmarshalled into v.
func HandleLoginForm ¶
func HandleLoginForm( ctx context.Context, w http.ResponseWriter, req *http.Request, idpChoice params.IDPChoiceDetails, tmpl *template.Template, loginUser func(ctx context.Context, username, password string) (*store.Identity, error), ) (*store.Identity, error)
HandleLoginForm is a handler that displays and process a standard login form.
func NameWithDomain ¶
NameWithDomain builds a name out of name and domain. If domain is empty then name is returned unchanged.
func RedirectURL ¶
RedirectURL creates a URL addressed to the given path within the IDP handler and adds the given state.
func RegistrationForm ¶
func RegistrationForm(ctx context.Context, w http.ResponseWriter, params RegistrationParams, t *template.Template) error
RegistrationForm writes a registration form to the given writer using the given parameters.
func RequestParams ¶
func RequestParams(ctx context.Context, w http.ResponseWriter, req *http.Request) httprequest.Params
RequestParams creates an httprequest.Params object from the given fields.
func ServiceURL ¶
ServiceURL determines the URL within the specified location. If the given dest is a relative URL then a new url is calculated relative to location, otherwise it is returned unchanged.
Types ¶
type LoginFormParams ¶
type LoginFormParams struct { params.IDPChoiceDetails // Action contains the action parameter for the form. Action string // Error contains an error message from the previous, failed, // login attempt. Error string }
LoginFormParams contains the parameters sent to the login-form template.
type LoginState ¶
type LoginState struct { // ReturnTo holds the address to return to after the login has // completed. ReturnTo string // State holds an opaque value from the original requesing server // that will be sent back to the ReturnTo URL when the login // attempt completes. State string // Expires holds the time that this login attempt should expire. Expires time.Time // ProvideID holds the ProviderID of an authenticated user. It is // only used when the user that has authenticaated requires // registration. ProviderID store.ProviderIdentity }
LoginState holds the state of the current loging process.
type RegistrationParams ¶
type RegistrationParams struct { // State contains some opaque state for the registration. It can // be used to pass arbitrary data back to the idp once the // registration is processed. State string // Username contains the preferred username for the user. This // will be used to populate the username input. Username string // Error contains an error message if the registration failed. Error string // Domain contains the domain in which the user is being created. // This cannot be modified by the user. Domain string // FullName contains the full name of the user. This is used to // populate the fullname input. FullName string // Email contains the email address of the user. This is used to // populate the email input. Email string }