-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix/refactor: Move auth.token_key
and other parameters to AuthConfig
structure
#925
Conversation
fecf453
to
dbc5e13
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactor is good. I would like the option to be used instead of the viper call consistently. The comment about config file pointing to another file or environment variable is more for later I think.
48af093
to
1fb4c4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have more comments later, but the code in handlers_auth.go
I think needs to change if we're doing this. (That is the only part of the code which is that way, so I'd be happy to see it fixed.)
internal/crypto/crypto.go
Outdated
// EngineFromAuthConfig creates a new crypto engine from an auth config | ||
func EngineFromAuthConfig(authConfig *config.AuthConfig) (*Engine, error) { | ||
if authConfig == nil { | ||
return nil, errors.New("auth config is nil") | ||
} | ||
|
||
if authConfig.TokenKey == "" { | ||
return nil, errors.New("token key is empty") | ||
} | ||
|
||
return &Engine{ | ||
encryptionKey: authConfig.TokenKey, | ||
}, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of reversing this dependency, and having config.go
have an .Engine()
method?
It looks like the other usage is configuration params in GeneratePasswordHash
, and I'd sort of prefer a non-magic struct as an argument there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhm... can't really add an Engine
method without introducing an import cycle
…ig` structure The intent is to have a central place to fetch the configuration and validate it. This way, starting the server will fail if the needed crypto configuration is not set up appropriately. This also moves the `crypto` package to `internal` which is more appropriate. Finally, the concept of `auth.token_key` changed from being a string to being a file. The idea is that we'll have all secrets as files which will be referenced as kubernetes secrets. Closes: #923
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only comment with the auth key being a string was resolved, so I'm happy with this PR version.
Add token_key_passphrase to file location overrides following #925
The intent is to have a central place to fetch the configuration and validate it.
This way, starting the server will fail if the needed crypto configuration is not
set up appropriately.
This also moves the
crypto
package tointernal
which is more appropriate.Closes: #923