idputil

package
v1.0.0-alpha4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2018 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package idputil contains utility routines common to many identity providers.

Index

Constants

View Source
const RedirectCookieName = "candid-redirect"

RedirectCookieName is the name of the cookie used to store RedirectState whilst a login is being processed by a third-party server.

Variables

View Source
var ReservedUsernames = map[string]bool{
	"admin":    true,
	"everyone": true,
}

Functions

func DischargeID

func DischargeID(req *http.Request) string

DischargeID gets the discharge ID from the given request using the standard form value.

func GetLoginMethods

func GetLoginMethods(ctx context.Context, c *httprequest.Client, u *url.URL, v interface{}) error

GetLoginMethods uses c to perform a request to get the list of available login methods from u. The result is unmarshalled into v.

func NameWithDomain

func NameWithDomain(name, domain string) string

NameWithDomain builds a name out of name and domain. If domain is empty then name is returned unchanged.

func RedirectParams

func RedirectParams(req *http.Request) (returnTo, state string)

RedirectParams gets the return_to and state parameters from the request.

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 URL

func URL(prefix, path, dischargeID string) string

URL creates a URL addressed to the given path within the IDP handler and adds the given dischargeID (when specified).

Types

type RedirectState

type RedirectState struct {
	ReturnTo string
	State    string
}

RedirectState holds the incoming return address and state in a redirect based login.

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL