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

fix: Weave GitOps username is hard-coded #2086

Merged
merged 3 commits into from
May 5, 2022
Merged

Conversation

yitsushi
Copy link
Contributor

@yitsushi yitsushi commented May 4, 2022

Create addition RoleBinding and ClusterRoleBinding based on the
username, and keep the original wego-admin there to maintain backward
compatibility.

DevMode with Tilt still uses wego-admin as a hard-coded user,
potentially we can even remove the DevUser maybe.

DevMode is used only to set DevUser on HMACTokenSignerVerifier and
the user is used only return with a static claim on Verify().

Additional changes:

  • Split up the admin-user.yaml into logical parts like
    • Credentials as they will be created only once.
    • Role and ClustreRole as they will be created only once
    • Two files for RoleBinding and ClusterRoleBinding (as described above)

Fixes #2001

@yitsushi yitsushi added the bug Something isn't working label May 4, 2022
@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

image

@yitsushi yitsushi requested review from rokshana-b and Callisto13 May 4, 2022 09:59
Copy link
Contributor

@ozamosi ozamosi left a comment

Choose a reason for hiding this comment

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

Changes to the chart will (just like documentation) be deployed straight to our end users. I believe this change would break all existing users, hence my change request.

Additionally, when you change the chart, you need to change the chart version, or the deploy becomes weird and we create 2 different "editions" of the same chart version.

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

Additionally, when you change the chart, you need to change the chart version, or the deploy becomes weird and we create 2 different "editions" of the same chart version.

I know that part, first I wanted some review if the approach is acceptable.

Changes to the chart will (just like documentation) be deployed straight to our end users. I believe this change would break all existing users, hence my change request.

When the Helm Chart is applied, the RoleBinding will be changed. I don't see why would it break. If they log in with an adminUser, the username/password pair will not change, the underlying RoleBinding will change, but the change will just use the same value as defined in adminUser (the one they use to log in), the only requirement would be to restart the server pod, but that will happen because of the code (and with that the container image) changes.

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

Tested workflow:

  • Used main while for dev-cluster
  • Log in as dev/dev and it shows wego-admin
  • Switched to this branch
  • Wait...
  • Log in as dev/dev and it shows dev and I see the same content

@ozamosi
Copy link
Contributor

ozamosi commented May 4, 2022

but that will happen because of the code (and with that the container image) changes.

No - merging this PR won't deploy core in any customer cluster. It will deploy the role binding. We can only do the chart change as part of a release.

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

No - merging this PR won't deploy core in any customer cluster. It will deploy the role binding. We can only do the chart change as part of a release.

That makes sense. So this can be merged only before we cut a new release?

Unfortunately I can't split it up code and chart changes. At least I don't see how can I do that.

@Callisto13
Copy link
Contributor

Callisto13 commented May 4, 2022

dejavu

I think this is something we do not want. It was a deliberate choice to have the k8s object User to always be called wego admin. I had a PR very similar to this a while ago (cannot find it anywhere) and was told that we do not want this. Basically the argument was that if we let it be configurable to this level, people can create any number of static users and we don't want to become an identity provider.
So basically, even though it feels "broken" to you and me, there is only ever one "user", regardless of what people think they are setting.

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

Closing this PR based on the discussion above.

@yitsushi yitsushi closed this May 4, 2022
@yitsushi yitsushi mentioned this pull request May 4, 2022
10 tasks
@Callisto13
Copy link
Contributor

Callisto13 commented May 4, 2022

the fact that we keep having these discussions, because it looks so weird to use and to implement, is... illuminating 😁

@Callisto13
Copy link
Contributor

Callisto13 commented May 4, 2022

This is the closest thing to a "summary issue" i can find. It has all the links to various discussions around this. I may write it up fully so we have an easy link in future for when this inevitably comes up again #1787

@ozamosi
Copy link
Contributor

ozamosi commented May 4, 2022

Unfortunately I can't split it up code and chart changes. At least I don't see how can I do that.

Add 2 users right now, and add a ticket to remove the old one after the next release, I suppose.

for when this inevitably comes up again

Given this has been reported about one time for every person who's tried to use this, could we just fix it instead? "We don't want this" isn't accurate - we clearly all do.

@Callisto13
Copy link
Contributor

you'd have to take it up with @davidstauffer

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

Given this has been reported about one time for every person who's tried to use this, could we just fix it instead? "We don't want this" isn't accurate - we clearly all do.

To be fair it's kind of documented:
image

Maybe we just have to highlight the fact that the username + password pair is only for authentication, the logged in user will be wego-admin.

@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

if we let it be configurable to this level, people can create any number of static users and we don't want to become an identity provider.

Technically with this approach they still can have only one user, because we read the user/pass from a single and hard-coded Secret, so no way they can create more than one user without changing the mechanism used to fetch auth credentials from Secret.

@JamWils
Copy link
Contributor

JamWils commented May 4, 2022

Alright, I think we should reopen this since it is a topic that keeps coming up.

  1. Let's not break existing users so do what needs to be done.
  2. The name can be configurable via helm chart values and it defaults to wego-admin.
  3. This is the only role binding we provide in the chart. This is effectively our one user. We can't stop users from setting up more users then there already are, but that is on them. They could do it now if they wanted to by uploading the correct yaml along side the helm release.

@yitsushi yitsushi reopened this May 4, 2022
@yitsushi yitsushi marked this pull request as draft May 4, 2022 14:46
@yitsushi yitsushi requested a review from ozamosi May 4, 2022 15:34
@yitsushi yitsushi marked this pull request as ready for review May 4, 2022 15:39
@yitsushi
Copy link
Contributor Author

yitsushi commented May 4, 2022

Why the HelmChart test fails... updated the chart version :/

Copy link
Contributor

@ozamosi ozamosi left a comment

Choose a reason for hiding this comment

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

🎉

Not sure about the failed check - I added it, and it's clearly not doing what it should, so I need to debug it. I'm happy for you to ignore it and merge regardless.

@ozamosi
Copy link
Contributor

ozamosi commented May 4, 2022

Fixed the chart check in #2094

username, and keep the original `wego-admin` there to maintain backward
compatibility.

`DevMode` with Tilt still uses `wego-admin` as a hard-coded user,
potentially we can even remove the `DevUser` maybe.

`DevMode` is used only to set `DevUser` on `HMACTokenSignerVerifier` and
the user is used only return with a static claim on `Verify()`.

Additional changes:
* Split up the admin-user.yaml into logical parts like
  * Credentials as they will be created only once.
  * Role and ClustreRole as they will be created only once
  * Two files for RoleBinding and ClusterRoleBinding (as described above)
@yitsushi yitsushi force-pushed the 2001-username-on-the-ui branch from 5f753e5 to 6b9fb36 Compare May 5, 2022 08:05
@yitsushi yitsushi merged commit 53d4bbd into main May 5, 2022
@Callisto13
Copy link
Contributor

They could do it now if they wanted to by uploading the correct yaml along side the helm release.

Should we add something in docs (in another pr) that if ppl want to add more users, it is at their own risk and we are doing (will always do) the bare minimum when it comes to being an identity provider, and that they should def use oidc?

@yitsushi
Copy link
Contributor Author

yitsushi commented May 5, 2022

They could do it now if they wanted to by uploading the correct yaml along side the helm release.

How can they add more users?

The code behind the scene will be still the same and it will check only the cluster-user-auth secret. I don't see any options to tell the system "use that secret too".

Right now I think the only way people can use multiple users is OIDC.

they can create Roles and RoleBindings, but login user will be only one without OIDC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weave GitOps username is hard-coded
4 participants