Skip to content
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

MBS-8041 Refresh expired OpenID token #297

Merged
merged 3 commits into from
Apr 4, 2020
Merged

Conversation

eugene-krivobokov
Copy link
Contributor

We support Open Id tokens in k8s for authentication and authorization.
kubectl refreshes tokens automatically and stores changes to kube config file.

Kubernetes - OpenID Connect Tokens

How they look in the config:

users:
- name: username
  user:
    as-user-extra: {}
    auth-provider:
      config:
        client-id: k8s
        client-secret: xxx
        extra-scopes: groups
        id-token: xxx                       <-------
        idp-issuer-url: https://xxx
        refresh-token: xxx
      name: oidc

id-token is the Open id token in Jwt format:

{
 "iss":"https://xxx",
 "sub":"xxx",
 "aud":"k8s",
 "exp":1585929826,  <---
 "iat":000,
 "at_hash":"xxx",
 "email":"user@mail",
  

exp - is the expiration date. This is how the client knows it in advance.

Unfortunately, fabric8 kubernetes-client doesn't refresh tokens.
I've reused implementation from the official client (kubernetes-client/java#871)

Known issues:

  • The client persists yaml correctly but with another formatting style. I think we can live with it for now.

require(getNamespace() == namespace) {
"kubernetes.context.namespace should be $namespace. " +
"Namespace hardcoded in plugin, and this check only prevents from using wrong context"
}
requestConfig.oauthTokenProvider = oauthTokenProvider(configFile)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -20,6 +20,7 @@ sealed class KubernetesCredentials : Serializable {
) : KubernetesCredentials(), Serializable
}

// TODO: get rid of this default. autoConfig is enabled by default
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refactoring is out of scope

@mergify mergify bot merged commit 4ab186c into develop Apr 4, 2020
@mergify mergify bot deleted the MBS-8041-oidc-refresh branch April 4, 2020 20:01
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