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

✨ Improve session handling with a secure session key #2154

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

zhanggbj
Copy link
Contributor

@zhanggbj zhanggbj commented Aug 3, 2023

What this PR does / why we need it:
Improve session handling with a secure session key to avoid hijack.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 3, 2023
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 3, 2023
@zhanggbj zhanggbj changed the title Improve session handling with a secure session key ✨ Improve session handling with a secure session key Aug 3, 2023
pkg/session/session.go Outdated Show resolved Hide resolved
pkg/session/session.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 4, 2023
@zhanggbj zhanggbj force-pushed the secure_session branch 2 times, most recently from a67dfb2 to c463665 Compare August 4, 2023 03:01
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 4, 2023

Thanks for your review, and all comments are addressed, including

  • Only hashed password, so the sessionKey itself should be still human readable
  • For logging, just log server, datacenter and username which is in plain text for debugging, but won't log sessionKey with the key structure and an hashed password
  • Also adjust function parameters

pkg/session/session.go Outdated Show resolved Hide resolved
pkg/session/session.go Outdated Show resolved Hide resolved
pkg/session/session.go Outdated Show resolved Hide resolved
pkg/session/session.go Outdated Show resolved Hide resolved
pkg/session/session.go Outdated Show resolved Hide resolved
@sbueringer
Copy link
Member

Just nits

@sbueringer sbueringer added this to the v1.8 milestone Aug 4, 2023
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 7, 2023
@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 7, 2023

/test pull-cluster-api-provider-vsphere-e2e-main

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 7, 2023

/retest

@chrischdi
Copy link
Member

/test pull-cluster-api-provider-vsphere-e2e-main

Copy link
Member

@laozc laozc left a comment

Choose a reason for hiding this comment

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

I think #2171 is going to add the SAML login which may impact the userinfo used here.
There are more fields to be added in the SAML case.

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 7, 2023

@laozc thanks for the highlight, checking...

@sbueringer
Copy link
Member

sbueringer commented Aug 7, 2023

I think #2171 is going to add the SAML login which may impact the userinfo used here. There are more fields to be added in the SAML case.

Thx, but let's tackle this one at a time.

I think the current PR is fine as is and I also would like to get this into v1.8.0 and backport it into all branches. We can then discuss in the other PR how to build on top

/lgtm
/assign @chrischdi

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 7, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 9c7813c99e1691714625c5d2041816c5dc3eb899

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 8, 2023

/test pull-cluster-api-provider-vsphere-e2e-main

@chrischdi
Copy link
Member

/retest

@sbueringer
Copy link
Member

/approve

pending CI/Prow

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 8, 2023
@sbueringer
Copy link
Member

/retest

@sbueringer
Copy link
Member

/cherry-pick release-1.7

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.7 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sbueringer
Copy link
Member

/cherry-pick release-1.6

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.6 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sbueringer
Copy link
Member

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot merged commit 1013a3a into kubernetes-sigs:main Aug 8, 2023
4 checks passed
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #2190

In response to this:

/cherry-pick release-1.7

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: #2154 failed to apply on top of branch "release-1.6":

Applying: Improve session handling with a secure session key
Using index info to reconstruct a base tree...
M	pkg/session/session.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/session/session.go
CONFLICT (content): Merge conflict in pkg/session/session.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve session handling with a secure session key
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.6

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-infra-cherrypick-robot

@sbueringer: #2154 failed to apply on top of branch "release-1.5":

Applying: Improve session handling with a secure session key
Using index info to reconstruct a base tree...
M	pkg/session/session.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/session/session.go
CONFLICT (content): Merge conflict in pkg/session/session.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve session handling with a secure session key
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@sbueringer
Copy link
Member

@zhanggbj if you have some time, can you please open cherry-picks for 1.5 and 1.6?

@zhanggbj
Copy link
Contributor Author

zhanggbj commented Aug 9, 2023

@sbueringer Sure, will open cherry-picks today

zhanggbj added a commit to zhanggbj/cluster-api-provider-vsphere that referenced this pull request Aug 9, 2023
zhanggbj added a commit to zhanggbj/cluster-api-provider-vsphere that referenced this pull request Aug 9, 2023
zhanggbj added a commit to zhanggbj/cluster-api-provider-vsphere that referenced this pull request Aug 9, 2023
Manually cherry-pick kubernetes-sigs#2154 to resovle conflicts

Signed-off-by: Gong Zhang <[email protected]>
zhanggbj added a commit to zhanggbj/cluster-api-provider-vsphere that referenced this pull request Aug 9, 2023
Manually cherry-pick kubernetes-sigs#2154 to resolve conflicts

Signed-off-by: Gong Zhang <[email protected]>
zhanggbj added a commit to zhanggbj/cluster-api-provider-vsphere that referenced this pull request Aug 9, 2023
Manually cherry-pick kubernetes-sigs#2154 to resolve conflicts

Signed-off-by: Gong Zhang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants