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

Authorization support for Portworx #324

Merged
merged 5 commits into from
Apr 1, 2019
Merged

Authorization support for Portworx #324

merged 5 commits into from
Apr 1, 2019

Conversation

lpabon
Copy link
Member

@lpabon lpabon commented Apr 1, 2019

What type of PR is this?
feature

This change is a continuation of @pault84 's PR #302
Moved here from #323 to bring the branch from a fork to origin.

What this PR does / why we need it:
Stork/Portworx driver must have the appropriate token to communicate with Px. Some functions require stork to generate its own token based on a shared secret JWT. Most calls have stork extract the token from a secret pointed by the annotations in the CRD.

Also this PR has the following updates (saved as separate commits):

  • TLS support in gRPC
  • Authorization support for gRPC calls like the ClusterDomain calls.
    • For this, the volume driver interface had to be edited to pass in the crd object. That way we could get the annotations which point to the secret containing the token.

Does this PR change a user-facing CRD or CLI?:
Yes, This requires only that a secret is saved in the annotations.

Is a release note needed?:
Not sure. Maybe regular documentations will be needed in the docs for Portworx

Does this change need to be cherry-picked to a release branch?:
I think so, but I am not sure which branch would be needed for Portworx release.

Copy link

@harsh-px harsh-px left a comment

Choose a reason for hiding this comment

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

still reviewing

drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
@harsh-px
Copy link

harsh-px commented Apr 1, 2019

I see vendor updates in the PR but no change in Gopkg.lock.

@harsh-px harsh-px assigned harsh-px and lpabon and unassigned harsh-px Apr 1, 2019
@harsh-px harsh-px requested a review from disrani-px April 1, 2019 05:05
@harsh-px harsh-px added the release-note Information about this change needs to be added to the release note label Apr 1, 2019
Expiration: time.Now().Add(time.Hour).Unix(),
}

token, err := auth.Token(claims, signature, options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why generate this token for every call? We should store it and regenerate when it expires.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a good point, but that would mean tracking tokens with time. If a token is expired generated a new one, and so on. I think we can do that, but that complexity I would like to move to another PR for later, if you don't mind. Currently generating a token each time is very fast.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generating a token is expensive if done very often, they involve crypto calls. Please file a bug to track that.
Example of how kubernetes deals with OIDC tokens to alleviate this: https://github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/oidc/oidc.go#L332

Copy link
Member Author

Choose a reason for hiding this comment

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

OIDC is different because it is an RPC connection to get the public auth key. We only generate it. But I'm not against it. I can change it to do this, I just suggested we do this after.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #325

drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
@disrani-px disrani-px added this to the 2.2.0 milestone Apr 1, 2019
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
drivers/volume/portworx/portworx.go Outdated Show resolved Hide resolved
@lpabon lpabon force-pushed the auth-2 branch 2 times, most recently from 9a2105b to eb07bb9 Compare April 1, 2019 20:45
@codecov
Copy link

codecov bot commented Apr 1, 2019

Codecov Report

Merging #324 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
- Coverage   72.71%   72.67%   -0.05%     
==========================================
  Files          24       24              
  Lines        2104     2104              
==========================================
- Hits         1530     1529       -1     
- Misses        444      445       +1     
  Partials      130      130
Impacted Files Coverage Δ
pkg/monitor/monitor.go 45.28% <0%> (-0.95%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 218aba5...aa9ca0d. Read the comment docs.

Expiration: time.Now().Add(time.Hour).Unix(),
}

token, err := auth.Token(claims, signature, options)
Copy link
Contributor

Choose a reason for hiding this comment

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

Generating a token is expensive if done very often, they involve crypto calls. Please file a bug to track that.
Example of how kubernetes deals with OIDC tokens to alleviate this: https://github.com/kubernetes/client-go/blob/master/plugin/pkg/client/auth/oidc/oidc.go#L332

@lpabon lpabon merged commit 0c9f5e4 into master Apr 1, 2019
@disrani-px disrani-px deleted the auth-2 branch May 20, 2019 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note Information about this change needs to be added to the release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants