-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support Boolean and boolean as a valid injection point. #218
Conversation
I've added a test (and it is failing on purpose) so we can see the issue. |
@sberyozkin any thoughts about this? |
@sberyozkin I'm proposing some changes to make the injection more consistent. I've tried to be conservative on the changes. One of the main issues is our What this PR does, is to retrieve the actual type that needs to be injected and I have implemented a few rules to provide manual conversions. I think we can improve this with some of the Conversion code I'm working on in the other project, but I wanted to keep things simple for now and not be too disruptive. Also, the way we produce the Claims is somehow limited, with fixed producers for each type. For instance, we are unable to produce a proper My recommendation would be to refactor all the injection code and do it like SmallRye Config. We can observe all of the Finally, the TCK is not covering everything. It covers most cases, but to make things fun, you can inject the same value in 8 or 9 different way. Look at @Inject
@Claim("long")
private long longClaim;
@Inject
@Claim("long")
private Long longClaimWrapper;
@Inject
@Claim("long")
private ClaimValue<Long> longClaimValue;
@Inject
@Claim("long")
private Optional<Long> longOptional;
@Inject
@Claim("long")
private ClaimValue<Optional<Long>> longClaimValueOptional;
@Inject
@Claim("long")
private JsonNumber longJson;
@Inject
@Claim("long")
private Optional<JsonNumber> longOptionalJson;
@Inject
@Claim("long")
private ClaimValue<JsonNumber> longClaimValueJson;
@Inject
@Claim("long")
private ClaimValue<Optional<JsonNumber>> longClaimValueOptionalJson; I guess we overcomplicated this a little bit :) |
@radcortez Sorry for a delay, IMHO we need give the implementations a chance to keep it internally in whatever way they prefer. I believe our own set should have all custom types kept converted to JSON objects/etc as it is what is expected by default (except when it is a String, long, etc) There is nothing wrong IMHO with the code above, but I'd say it is the users who want to inject |
@radcortez I propose that you update this PR around the PR subject only (boolean/Boolean support) - anything else can indeed be discussed in a different issue, thanks |
Not sure if I agree. Our CDI injection code has some flaws and I believe it would be easier to tackle this as a whole than just fixing the issues for
I think we will spent considerable more effort if we handle this separately. |
I'm not very concerned that some extra time will be spent to fix all properly. IMHO splitting one PR into a few ones would not involve a It is easier to me to review, make sure that I don't miss something, given the sensitivity around all these conversions. I'm not worried right now that for example This PR touches on too many things, For example, you have mentioned I agree though that Lets focus on the |
9a37ee5
to
0641556
Compare
The issue is in the spec, since we allow in the spec for multiple combinations of injection types, and the interesting thing is that the TCK don't ever cover them all. So, we do pass the TCK, but the TCK is not testing all combinations specified in the spec, which is another problem.
I think it is. If we are able to use Anyway, I've reverted most changes and added only consistent I'm opening another issue regarding the inconsistencies that we have. |
This is some work to support microprofile/microprofile-jwt-auth#127.
An interesting this is that the spec includes support for
Boolean
, but there is not TCK test for it, so it was never implemented in SmallRye JWT.While doing the work, I've also found another issue. Our
ClaimValue
support does not unwrapJsonValue
to wrapper primitive types. So if you try to inject a customClaimValue<Long>
you will get aClassCastException
, since for some reason we are wrapping the original claimSet inDefaultJWTCallerPrincipal#fixJoseTypes
This doesn't happen with
ClaimValue<Long>
ofaud
for instance, because we are not remapping that claim name so it works fine.I think we need to change this and don't modify the original claims set. This will fix the injection for wrapper primitive types. If we need a
JsonValue
type of sub class of it, we need to verify the injection point and do the conversion on the fly. Actually, this could be handled by the conversion work being done in #212 .