Skip to content

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

Merged
merged 1 commit into from
Jul 5, 2017

Conversation

brendandburns
Copy link
Contributor

Partial fix for #35

@mbohlool mbohlool requested a review from lwander June 28, 2017 20:30
Copy link
Contributor

@lwander lwander left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Persiter/Persister

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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!)

@brendandburns brendandburns force-pushed the plugins branch 3 times, most recently from 6ad6f3b to a7a0c57 Compare July 1, 2017 05:18
@brendandburns
Copy link
Contributor Author

@lwander rebased, let me know if you have any last comments, otherwise, I'll merge later today.

Thanks!

@lwander
Copy link
Contributor

lwander commented Jul 5, 2017

Looks good!

@brendandburns brendandburns merged commit ad22d1e into kubernetes-client:master Jul 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants