auth
139:026adb0c7fc4
Go to Latest
auth/config.go
Test our GetClientHandler function, add isAuthError helper.
Add a helper that identifies whether the error passed to it is an authentication
error or is some other type of error. This is useful fo checking whether or not
an internal error occurred while authenticating users.
Update all instances where we call our authentication helper to make them use
the new error helper. All tests continue to pass.
Add a new test case for retrieving a client as an unauthenticated user. This
clears the client's secret from the response before sending it.
Update the GetClientHandler function to return the secret when the owner of the
client used Basic Auth in the request.
Add a new test case for retrieving a client as an authenticated user, both the
owner and a non-owner user. This makes sure the secret is divulged only in the
appropriate cases.
10 // ErrInvalidLoginURI is returned when a Context is instantiated with a Config object that specifies a LoginURI that can't be parsed as a URL.
11 ErrInvalidLoginURI = errors.New("invalid login URI")
12 // ErrConfigNotInitialized is returned when a Context is instantiated with a Config object that hasn't had its Init function called.
13 ErrConfigNotInitialized = errors.New("config not initialized")
16 // Config holds the configuration values necessary to run a server. A Config
17 // instance is the only way to instantiate a Context variable.
19 ClientStore clientStore
20 AuthCodeStore authorizationCodeStore
21 ProfileStore profileStore
23 SessionStore sessionStore
25 Template *template.Template
31 // Init is a function that preps the Config object to be used for Context creation, setting variables
32 // that are determined at the beginning of program execution.
33 func (c *Config) Init() error {
34 scheme, ok := passphraseSchemes[CurPassphraseScheme]
36 return ErrInvalidPassphraseScheme
39 c.iterations, err = scheme.calculateIterations()
43 log.Printf("Generating passphrases with %d iterations...\n", c.iterations)