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

Allow preset filtering by domains and emails #7239

Merged
merged 3 commits into from Jun 30, 2021

Conversation

Happy2C0de
Copy link
Contributor

@Happy2C0de Happy2C0de commented Jun 17, 2021

Signed-off-by: Happy2C0de 46957159+Happy2C0de@users.noreply.github.com

What this PR does / why we need it:
It improves the preset filtering but keeps things simple and backwards compatible.
I introduced RequiredEmails as an option on the preset type. It gives users the possibility to limit certain presets to a list of domains and even on specific emails. Both in parallel. This includes the RequiredEmailDomain functionality but the variable is kept in place for backward compatibility.

The RequiredEmailDomain is appended to RequiredEmails such that both work in parallel and that the backward compatibility is assured. Added tests will take care of that.

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 #

Special notes for your reviewer:
I added several tests in order to verify the functionality.

Documentation:

Does this PR introduce a user-facing change?:

Adds support for RequiredEmails for improved presets filtering. RequiredEmailDomain is deprecated and might go away in a future release.

Signed-off-by: Happy2C0de <46957159+Happy2C0de@users.noreply.github.com>
@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. sig/api Denotes a PR or issue as being assigned to SIG API. sig/cluster-management Denotes a PR or issue as being assigned to SIG Cluster Management. labels Jun 17, 2021
@kubermatic-bot
Copy link
Contributor

Hi @Happy2C0de. Thanks for your PR.

I'm waiting for a kubermatic member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@kubermatic-bot kubermatic-bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 17, 2021
@Happy2C0de Happy2C0de changed the title Allos preset filtering by domains and emails Allow preset filtering by domains and emails Jun 17, 2021
@Happy2C0de
Copy link
Contributor Author

Question:
How easy is it to additionally implement a filtering based on projects. Somehow, the multi-tenancy is not completely working with the approach of limiting Presets based on emails. Are there any thoughts on this?
Thanks in advance.

@Happy2C0de
Copy link
Contributor Author

/assign @kgroschoff @moelsayed

…Emails

Signed-off-by: Happy2C0de <46957159+Happy2C0de@users.noreply.github.com>
@kgroschoff kgroschoff requested a review from zreigz June 22, 2021 11:05
@zreigz
Copy link
Contributor

zreigz commented Jun 22, 2021

/ok-to-test

@kubermatic-bot kubermatic-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 22, 2021
@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

/test pre-kubermatic-etcd-launcher-e2e

@Happy2C0de
Copy link
Contributor Author

@zreigz I think the failures are due to some environment problems. They aren't related to this PR. Can you have a look on your side? Thanks

@zreigz
Copy link
Contributor

zreigz commented Jun 22, 2021

/retest

@zreigz
Copy link
Contributor

zreigz commented Jun 22, 2021

@zreigz I think the failures are due to some environment problems. They aren't related to this PR. Can you have a look on your side? Thanks

probably our CI

@Happy2C0de
Copy link
Contributor Author

/retest

2 similar comments
@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

@zreigz LGTM, is there something hindering you from merging this PR?

@zreigz
Copy link
Contributor

zreigz commented Jun 29, 2021

/lgtm
/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 33304b133e630e82bcc64f16cfbf53a22bc9cdcf

@zreigz zreigz requested a review from kron4eg June 29, 2021 06:17
// otherwise, it has to match the whole email
if len(domain) == 1 {
// domain provided
if len(userDomain) == 2 && strings.EqualFold(userDomain[1], domain[0]) {
Copy link
Member

Choose a reason for hiding this comment

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

Did you know that email can contain more then 1 @ symbol?

Copy link
Member

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.

Yes, I knew but you don't allow it anyway.
See: https://github.com/kubermatic/kubermatic/blob/master/pkg/provider/kubernetes/preset.go#L201
here, the current code is doing the exact same thing, except that it only allows domains. I don't see a reason why the current code is ok, but the new one gets blocked by this argument.
i.e.:

userDomain := strings.Split(userInfo.Email, "@")
if len(userDomain) == 2 && strings.EqualFold(userDomain[1], requiredEmailDomain) {

if a user has email foo@bar@acme.com. The current code is looking for bar!? The new code would allow you to set
requiredEmails: ["foo@bar@acme.com"] and everybody would be happy.

@kron4eg
Copy link
Member

kron4eg commented Jun 29, 2021

In general it's MUCH better to create a preliminary issue where we could have an opportunity to discuss the need and execution of a new feature.

@Happy2C0de
Copy link
Contributor Author

Happy2C0de commented Jun 29, 2021

@kron4eg
I agree in general. Discussions are very helpful and needed. Very good point 👍
I opened several issues and as you see, I am also willing to participate and invest time. Nevertheless, unless some code is present nobody is interested to check things.

Important things to discuss:

  • OIDC user creation is wrong, it binds on emails and not OIDC 'sub'. Emails are unique but not persistent. Identity providers allow to change emails in no time. (see 7291)
  • Preset should bind to projects. (emails is fine too, if one would specify certain users within a project to be allowed to see the perset) I think, this is very important for the multi-tenancy that you strive for. (see 7260)
  • IPV4-IPV6 Dual-Stack support (see 6610)
    ...

Nobody, gave me an answer to none of these issues even though the first two issues, are kind of relevant for your main points. OIDC integration and multi-tenancy.
I understand that all of you are busy, but you have to tell me if you don't like that externals participate.

Signed-off-by: Happy2C0de <46957159+Happy2C0de@users.noreply.github.com>
@kubermatic-bot kubermatic-bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2021
Copy link
Member

@kron4eg kron4eg left a comment

Choose a reason for hiding this comment

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

/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2021
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: b3238dcf72d59dc654542dd9fa660b69a47dce56

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Happy2C0de, kron4eg, zreigz

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

@kubermatic-bot kubermatic-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2021
@Happy2C0de
Copy link
Contributor Author

/retest pre-kubermatic-opa-e2e

@kubermatic-bot
Copy link
Contributor

@Happy2C0de: The /retest command does not accept any targets.
The following commands are available to trigger jobs:

  • /test pre-kubermatic-kubermatic-validate-prow-yaml
  • /test pre-kubermatic-test
  • /test pre-kubermatic-verify
  • /test pre-kubermatic-verify-charts
  • /test pre-kubermatic-verify-shfmt
  • /test pre-kubermatic-verify-kubermatic-chart
  • /test pre-kubermatic-verify-grafana-dashboards
  • /test pre-kubermatic-verify-docs
  • /test pre-kubermatic-lint
  • /test pre-kubermatic-spellcheck
  • /test pre-kubermatic-dependencies
  • /test pre-kubermatic-shellcheck
  • /test pre-kubermatic-license-validation
  • /test pre-kubermatic-verify-boilerplate
  • /test pre-kubermatic-prometheus-rules-validation
  • /test pre-kubermatic-user-cluster-prometheus-config-validation
  • /test pre-kubermatic-simulate-github-release
  • /test pre-kubermatic-test-helm-charts
  • /test pre-kubermatic-e2e-aws-flatcar-1.18
  • /test pre-kubermatic-e2e-aws-ubuntu-1.19
  • /test pre-kubermatic-e2e-aws-ubuntu-1.20
  • /test pre-kubermatic-e2e-aws-ubuntu-1.21
  • /test pre-kubermatic-e2e-aws-ubuntu-1.21-ce
  • /test pre-kubermatic-e2e-azure-ubuntu-1.21
  • /test pre-kubermatic-e2e-gcp-ubuntu-1.21
  • /test pre-kubermatic-e2e-gcp-ubuntu-1.21-psp
  • /test pre-kubermatic-e2e-do-centos-1.21
  • /test pre-kubermatic-e2e-packet-ubuntu-1.21
  • /test pre-kubermatic-e2e-kubevirt-centos-1.21
  • /test pre-kubermatic-e2e-hetzner-ubuntu-1.21
  • /test pre-kubermatic-e2e-openstack-ubuntu-1.21
  • /test pre-kubermatic-e2e-openstack-centos-1.21
  • /test pre-kubermatic-e2e-vsphere-ubuntu-1.21
  • /test pre-kubermatic-e2e-vsphere-ubuntu-1.21-customfolder
  • /test pre-kubermatic-e2e-vsphere-ubuntu-1.21-datastore-cluster
  • /test pre-kubermatic-api-e2e
  • /test pre-kubermatic-etcd-launcher-e2e
  • /test pre-kubermatic-nodeport-proxy-e2e
  • /test pre-kubermatic-opa-e2e
  • /test pre-kubermatic-expose-strategy-e2e
  • /test pre-kubermatic-e2e-gcp-offline
  • /test pre-kubermatic-test-integration

Use /test all to run the following jobs:

  • pre-kubermatic-kubermatic-validate-prow-yaml
  • pre-kubermatic-test
  • pre-kubermatic-verify
  • pre-kubermatic-verify-kubermatic-chart
  • pre-kubermatic-verify-docs
  • pre-kubermatic-lint
  • pre-kubermatic-spellcheck
  • pre-kubermatic-dependencies
  • pre-kubermatic-verify-boilerplate
  • pre-kubermatic-e2e-aws-flatcar-1.18
  • pre-kubermatic-e2e-aws-ubuntu-1.19
  • pre-kubermatic-e2e-aws-ubuntu-1.20
  • pre-kubermatic-e2e-aws-ubuntu-1.21
  • pre-kubermatic-e2e-aws-ubuntu-1.21-ce
  • pre-kubermatic-api-e2e
  • pre-kubermatic-etcd-launcher-e2e
  • pre-kubermatic-opa-e2e
  • pre-kubermatic-expose-strategy-e2e
  • pre-kubermatic-test-integration

In response to this:

/retest pre-kubermatic-opa-e2e

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.

@Happy2C0de
Copy link
Contributor Author

/retest

3 similar comments
@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

/retest

@Happy2C0de
Copy link
Contributor Author

@zreigz @kron4eg LGTM now

@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Also, here is a cat.
/meow

@kubermatic-bot
Copy link
Contributor

@kubermatic-triage-bot: cat image

In response to this:

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Also, here is a cat.
/meow

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.

@kubermatic-triage-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Also, here is a cat.
/meow

@kubermatic-bot
Copy link
Contributor

@kubermatic-triage-bot: cat image

In response to this:

/retest
This bot automatically retries jobs that failed/flaked on approved PRs

Review the full test history

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

Also, here is a cat.
/meow

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.

@kubermatic-bot kubermatic-bot merged commit baf8727 into kubermatic:master Jun 30, 2021
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api Denotes a PR or issue as being assigned to SIG API. sig/cluster-management Denotes a PR or issue as being assigned to SIG Cluster Management. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants