-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
support Keycloak roles #143
Conversation
client.RealmId = realm | ||
return &client, nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactoring - these aren't needed
@@ -19,7 +19,7 @@ func TestAccKeycloakUser_basic(t *testing.T) { | |||
realmName := "terraform-" + acctest.RandString(10) | |||
username := "terraform-user-" + acctest.RandString(10) | |||
attributeName := "terraform-attribute-" + acctest.RandString(10) | |||
attributeValue := acctest.RandString(300) | |||
attributeValue := acctest.RandString(250) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests were failing for me locally, probably due to #132. I am not sure why they pass in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I nearly raised an Issue about the local test failures, but assumed I'd missed some setup. I can report back on whether the functionality is sufficient, but don't think I have sufficient context to investigate the existing test failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry too much about the test failures, that's something I can look in to.
The changes I made will at least allow these tests to pass locally for me. I'd be curious to see if they pass locally for you as well if you pull my branch down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI - these failed locally and passed in CI because my local setup uses postgres, which uses a varchar(255)
column for user attributes, hence the failure. CI uses in-memory h2 which does not appear to have that limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using the client roles portion of this and it seems to work well!
Thanks for the feedback @fharding1. Do you use composite roles? I'll be finished with that within the next couple of days and there are a few things that I would like some feedback on relating to that. |
No problem, thank you for doing this work 🙏. We don't use composite roles, however, I can definitely mess around with that a bit and give some feedback. |
We use composite roles, so if that support gets added we'd love to try it out. |
Just pushed up support for composite roles (no tests yet, sorry). It works fine with the
To me, this diff kinda sucks because you don't really know which role is being removed here, just its ID, and you obviously wouldn't know or care about that. I can change the I'd be interested to hear someone else's thoughts on this. |
While it sucks, I wouldn't worry about it for a first version. We're likely to double check through the GUI and automated tests anyway, so trusting that the IDs line up is sufficient for now. |
I'll +1 what @camelpunch said. I think while it's not perfect that the IDs aren't very friendly, making more API calls isn't ideal either, and people should be checking results via the GUI anyways. I agree that this is totally fine for now. @mrparkers would you like some assistance with the last portion "assign roles to groups"? We would like to use this soon (and I definitely don't want to put any pressure on you to feel the need to rush this), so I would be happy to work on it if you're busy with the other portions. |
What were you thinking about doing for the HCL for client roles, since they're a map of strings to lists of strings and terraform doesn't support that? I was thinking it could be either a list of lists where you specify the client as the first value and the role as the second, or a map of strings to strings with the value being a comma separated list of roles. We could even do something like a list of strings where each string is "${client}.${role}". Another (probably cleaner, but quite different from the API and GUI) option could be to specify a list of IDs, that are looked up to get the client and role name, however this would likely be very expensive since you would have to look up all the clients and their roles. Not sure I like any of these. Thoughts? |
Actually, I just have I liked that approach because it works well with Keycloak's API, which doesn't treat client roles as an attribute on the client itself, but rather an independent resource. Let me know if this approach doesn't make sense and we can come up with a different way to handle it. |
I appreciate the offer! I have some time set aside today to finish this though, so I should be all good. |
I should have clarified that I was referring specifically to groups, and I was just looking at the GroupRepresentation in the docs that has realmRoles as a array and clientRoles as a map<string, array>, however I didn't even realize that there are endpoints like And awesome 🎉 figured I would ask. |
Thanks for adding the missing navbar link! |
… initial password
I just pushed up the One thing I noticed when messing with it was that adding a role to a group would "soft fail" if that role was already an "effective role", meaning that some other role with that role as a composite is already mapped to that group. I could use Depending on what everyone things of my progress here, all I have left to do is write docs, merge this, and cut a release. |
We've used the Otherwise we're chomping at the bit for a release. Thank you so much for rescuing us from monster-ball-of-JSON hell! |
I've been testing out |
We'd like to be able to attach client roles to users. Looking into the code this doesn't seem to be possible at the moment? Do you plan on supporting that use case? |
@rlewan I don't have a problem with adding support for that. Most of the hard work for that has already been taken care of in the Could you help me understand your case for assigning roles directly to users as opposed to groups of users? I'm just curious since it is not something I would personally use. |
@mrparkers I think this use case @rlewan was talking about was for service accounts attached to clients. |
@mrparkers exactly what @camelpunch said. We use service accounts for service-to-service communication, so far Keycloak UI allowed us to assign necessary client roles to those (Service Account Roles tab under Clients, the client has to be confidential and have service accounts enabled). |
Gotcha, that use case definitely makes sense. I forgot to consider that. I can definitely support that, but I'd like to double check with you first on the HCL you'd expect to use. I opened #152 to keep track of this and discuss the HCL you'd expect. I'm probably going to merge this PR and cut a release without this support just to keep things moving, but I can work on what you're asking for pretty soon afterwards. |
🎉 thanks again for adding this! |
Closes #102
cc @MatteoJoliveau, @xiaoyang-connyun, @dhardiker, @camelpunch
Please let me know if I'm missing anything from the list above. The work I have done so far fits my use case, but I don't want to merge this until it works for everyone who chimed in on #102.
The included
roles.tf
file is an example of what I have so far. I'll try to keep working on this throughout the week.