-
Notifications
You must be signed in to change notification settings - Fork 2k
Add an authenticator interface and implementation. #37
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
Conversation
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.
Looks good, just a few stylistic questions
String name = (String) authConfig.get("name"); | ||
Authenticator auth = authenticators.get(name); | ||
if (auth != null) { | ||
// TODO: Persiter here. |
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.
s/Persiter/Persister
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.
done.
@Override | ||
public String getToken(Map<String, Object> config, ConfigPersister persister) { | ||
Date expiry = (Date) config.get("expiry"); | ||
if (expiry != null && expiry.compareTo(new Date()) <= 0) { |
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.
Don't all tokens expire? Can this be moved in to an abstract super class with an abstract refreshToken
method?
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.
Refactored to do this.
* @param config The new configuration to persist | ||
* @throws IOException when an error occurs while persisting | ||
*/ | ||
void persistConfig(String name, Map<String, Object> config) throws IOException; |
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.
Why is the authenticator name required? It seems strange that you pass the ConfigPersister
to getToken
in the Authenticator
which will always have to supply its own name to persistConfig
.
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 was emulating what client-go does, but I got rid of this (and I like it better now, so thanks for the feedback!)
6ad6f3b
to
a7a0c57
Compare
@lwander rebased, let me know if you have any last comments, otherwise, I'll merge later today. Thanks! |
Looks good! |
Partial fix for #35