-
Notifications
You must be signed in to change notification settings - Fork 39
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
@OpenIdAuthenticationMechanismDefinition annotation is not repeatable in 4.0 #342
Comments
Hi, @fschoning, you need to assign a qualifier to at least one of your definitions. So, like this:
The mechanisms are for the whole application, they are not connected to the servlet where you define them. You have to add a custom handler to select which mechanism is used for which servlet. Here's an example in the TCK, with the Basic mechanism: CustomAuthenticationMechanismHandler.java#L47 For OpenID it's very similar - the OpenID annotation also supports the If one of your OpenID definitions doesn't specify the If more definitions don't specify it, you would see an error for ambiguous dependencies as you reported, because there will be more candidates for the default mechanism, which will conflict. In order to be able to switch between the mechanisms, you also need to implement a
|
Thanks for the pointer Ondro. I have added the qualifier parameters and the custom handler, but I still get an injection error. I moved the @OpenIdAuthenticationMechanismDefinition from my web servlet class and put both on the CustomAuthenticationMechanismHandler class as in the tck test. Here is my code:
And this is the error on deploy:
I am using Wildfly 34.0.0.preview and 34.0.1.preview both with the same result. I also attempted to create a jakarta ee security tck test by copying the test you referred to and changing it to use OpenID instead, but ran into too many build problems to get the tck test compiled and run (I had to remove copyright checks, and then got missing glassfish build errors and I gave up there). Appreciate any further pointers. Franz |
Interesting. I tried it on GlassFish 8 milestone and it doesn't work there either, I have the same result as you. However, when I replace This would be an issue for the Soteria project, which is used by both WildFly and GlassFish. Or directly for WildFly. The Security API is OK, the only issue is that the TCK doesn't test the case with OpenID annotations. |
Thanks for checking. Will you open the issue in Soteria? I see you are already adding a tck test for this. |
I create an issue for Soteria: eclipse-ee4j/soteria#389 I suggest that you create an issue for the WildFly team, @fschoning , so that they are aware. |
I am trying to use two different OIDC authentication provider clients within the same Wildfly 34 Preview JakartaEE 11 web application. As far as I understand, in Jakarta EE 3.0 this is not possible but has been made possible in 4.0 by using Qualifiers.
I have created two servlets, each with the @OpenIdAuthenticationMechanismDefinitionannotation and each with their own Qualifier annotation. However on deployment I still get the error: "Ambiguous dependencies for type OpenIdAuthenticationMechanismDefinition with qualifiers @default"
My code is as follows:
@Qualifier @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) public @interface QualifierA { }
@Qualifier @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) public @interface QualifierB { }
@QualifierA @OpenIdAuthenticationMechanismDefinition( providerURI = "${oidcConfigA.issuerUri}", clientId = "${oidcConfigA.clientId}", clientSecret = "${oidcConfigA.clientSecret}", redirectURI = "${baseURL}/oidcredirecturi", jwksReadTimeout = 5000, jwksConnectTimeout = 5000) @ServletSecurity(@HttpConstraint(rolesAllowed = "Everyone")) @WebServlet("/alogin") public class OidcLoginWebServletA extends HttpServlet {
@QualifierB @OpenIdAuthenticationMechanismDefinition( providerURI = "${oidcConfigB.issuerUri}", clientId = "${oidcConfigB.clientId}", clientSecret = "${oidcConfigB.clientSecret}", redirectURI = "${baseURL}/oidcredirecturi", jwksReadTimeout = 5000, jwksConnectTimeout = 5000) @ServletSecurity(@HttpConstraint(rolesAllowed = "Everyone")) @WebServlet("/blogin") public class OidcLoginWebServletB extends HttpServlet {
I do not know if I am using the feature wrong or if this is an issue? I cannot see an example of this in the tck tests.
The text was updated successfully, but these errors were encountered: