auth
173:b0d1b3e39fc8
Go to Latest
auth/config.go
Make client use our auth(n/z) scheme.
Our auth(n/z) scheme can be loosely defined as "encrypted tokens that nginx
transforms into headers" and "scopes for bypassing ACL". Our Go client, which is
what we'll be using to have services communicate with each other, follows this
paradigm now by auto-injecting the headers we'll need to identify ourselves.
This will work behind our firewall, but will be useless for the rest of the
world, which will need to go through the nginx bastion that can strip the
headers and replace them with the headers appropriate to the token attached to
the request.
This did involve setting a static client ID as the client for our
email_verification listener. Ideally, this would cause Client registration
(using that ID) when the listener starts up, ignoring ErrClientAlreadyExists. I
don't want to have to write the code that will allow us to bypass the Client ACL
properly right now, though, so we're just going to have to remember to manually
create that Client. Or not. I don't think it will do any harm (outside the OAuth
flow) to be using a Client ID that doesn't actually point to a Client. I just
think it'd be good for record-keeping purposes.
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")
15 // Version is used to keep track of what version of the build this is
19 // Config holds the configuration values necessary to run a server. A Config
20 // instance is the only way to instantiate a Context variable.
22 ClientStore clientStore
23 AuthCodeStore authorizationCodeStore
24 ProfileStore profileStore
26 SessionStore sessionStore
28 LoginVerificationNotifier loginVerificationNotifier
29 Template *template.Template
36 // Init is a function that preps the Config object to be used for Context creation, setting variables
37 // that are determined at the beginning of program execution.
38 func (c *Config) Init() error {
39 scheme, ok := passphraseSchemes[CurPassphraseScheme]
41 return ErrInvalidPassphraseScheme
44 c.iterations, err = scheme.calculateIterations()
48 log.Printf("Generating passphrases with %d iterations...\n", c.iterations)