-
Notifications
You must be signed in to change notification settings - Fork 315
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
Add Custom Identity Provider Mapper #515
Add Custom Identity Provider Mapper #515
Conversation
c81452c
to
8c16d88
Compare
@hamiltont yeah, thanks. |
8c16d88
to
c035f14
Compare
4180cc9
to
a7c747d
Compare
dc1dc80
to
9c70b70
Compare
9c70b70
to
251b2b4
Compare
Hey @bl00mber, thanks for the PR. Apologies for the delayed review. I'm struggling a bit with understanding how well this change solves the problem described in #382. My understanding of the problem here is that we'd like this provider to support custom identity provider mappers (similar to how the A better solution seems to be the approach outlined in #382, where a separate resource is created specifically for this purpose. What do you think about that? @hamiltont I'd appreciate your thoughts here too, I'm not super familiar with these features of Keycloak so I may need a bit of guidance. |
Sure! disclaimer - my golang is at a 'beginner' level, so I'm probably not understanding all of the nuance here, but my keycloak is somewhere around "advanced" so I can help out there I was indeed thinking the "right" solution would be a different resource type. To my untrained (on golang) eye, this PR looks to have some useful code that could be refactored and used, but the overall approach does look hacky. When I first opened the diff, I was expecting to see code that was a copy of one of the existing "identity provider mapper" source code files, such as For some context, here are the current source code usages of the "IDP mapper" type: Note there are four of them, because they correspond to the four builtin "identity provider mappers", as seen here: #382 is about adding a custom resource type that supports non built in options. For example, I have built some special mappers that utilize google OAuth APIs to collect additional data about a user if they have given consent to access that data. This is not a built-in (and the java code does not extend or subclass anything, it's a completely new implementation of an "identity provider mapper") Be aware of the common confusion between client mappers and IdP mappers. They are similar in concept (they map data), but an identity provider mapper is for mapping data from an external system (the idp) into the local keycloak system, while a client mapper is for the opposite e.g. mapping data from the local keycloak system into the claims you want to expose to a caller. They are also used at different places in the login flow (Idp mappers are used right after user login flows return from the IdP, while client mappers are typically used when a user auth is totally done and we are about to return the jwt) |
I do think #434 is a duplicate request as #382 , but it proposed a different solution approach that might be where @bl00mber got some inspiration for this PR. I do think the custom resource approach is better and more maintainable, but I happy defer to @mrparkers on what is considered clean maintainable code in golang |
This reverts commit 251b2b4.
7102465
to
286f06c
Compare
286f06c
to
4d70bb4
Compare
Thanks for the reviews! @mrparkers this way of implementation was selected because I've updated PR, allowing this field to be filled in separate resource instead. |
4d70bb4
to
8e6302e
Compare
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 like this approach better, thanks for making those changes! I just have a few comments
if identityProviderMapper, ok := data.GetOk("identity_provider_mapper"); !ok { | ||
return nil, fmt.Errorf(`provider.keycloak: keycloak_custom_identity_provider_mapper: %s: "identity_provider_mapper": should be set`, data.Get("name").(string)) | ||
} else { | ||
if strings.Contains(identityProviderMapper.(string), "%s") { |
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.
it looks like you can provide a format string to the identity_provider_mapper
attribute? this looks fine, but can this be added to the documentation so it's clear how to use this?
2233d3b
to
7d1bed2
Compare
7d1bed2
to
abf6629
Compare
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.
Sorry for taking so long to get back to this. Everything here looks good, thanks for submitting this PR!
@mrparkers any idea when this will make it into a release? |
https://github.com/mrparkers/terraform-provider-keycloak/releases/tag/v3.1.1 - sorry for the delay! |
@bl00mber: Could it be that this change can not handle the keyword "claim" (all lower case) as a param in extra_config? |
@tomrutsaert does this setting generates camelcase string, or lowercase string? |
So because of the unmarshal/marshal method and because @mrparkers what do you think? |
Yeah, the logic for marshalling and unmarshalling structs that have an This resource is sharing that If you want to open an issue for this @tomrutsaert, I can try to take a look later this week. Otherwise I'm happy to review a PR if you want to take a stab at it too. |
Actually, someone already opened #571 for this. I'll see if I can make some time sooner rather than later to address this since it's affecting multiple users. |
close #382, close #434