auth

Paddy 2014-12-14 Parent:e57a57a944c4 Child:e98d19699ee9

99:5bccbed6631b Go to Latest

auth/config.go

Add an endpoint to validate and register profiles. Add a newProfileRequest object that defines the user-specified properties of a new Profile. Add a helper that validates a newProfileRequest and modifies it for sanitization, mostly just removing leading and trailing whitespace. Add MaxNameLength, MaxUsernameLength, and MaxEmailLength constants to hold the maximum length for those properties. Add errors to be returned when a users attempts to log in with a profile that is compromised or locked. Add the bare bones of a CreateProfileHandler that validates a profile registration request adn uses it to create a Profile and at least one Login. Create a requestError struct that is used for returning API errors, along with constants for the slugs we'll use to signal those errors.

History
1 package auth
3 import (
4 "errors"
5 "html/template"
6 )
8 var (
9 // ErrInvalidLoginURI is returned when a Context is instantiated with a Config object that specifies a LoginURI that can't be parsed as a URL.
10 ErrInvalidLoginURI = errors.New("invalid login URI")
11 )
13 // Config holds the configuration values necessary to run a server. A Config
14 // instance is the only way to instantiate a Context variable.
15 type Config struct {
16 ClientStore clientStore
17 AuthCodeStore authorizationCodeStore
18 ProfileStore profileStore
19 TokenStore tokenStore
20 SessionStore sessionStore
21 Template *template.Template
22 LoginURI string
23 iterations int
24 }