1

I have a problem with defining parameters for an @OpenIdAuthenticationMechanismDefinition annotation introduced in the jakarta-ee-security-api of Jakarta EE 10. My goal is to understand the correct usage of expression language.

See this example:

@OpenIdAuthenticationMechanismDefinition(
        clientId = "123",
        clientSecret = "xxx",
        extraParameters = { "audience=abc", "team=def" }
)
public class MyBean  {
   ...
}

In this example I set 3 params hard coded. The Jakrata EE jakarta-ee-security-api also supports a more dynamic way using the Expression Language and referring to a CDI bean providing such values:

@OpenIdAuthenticationMechanismDefinition(
        clientId = "${configBean.clientId}",
        clientSecret = "${configBean.clientSecret}",
        extraParameters = { "audience=abc", "team=def" }
)
public class MyBean  {
   ...
}

This works all fine. My problem in this example is the parameter extraParameters which is expecting a string array. I did not manage to set this param by a config CDI Bean like in the following example code:

@OpenIdAuthenticationMechanismDefinition(
        clientId = "${configBean.clientId}",
        clientSecret = "${configBean.clientSecret}",
        extraParameters = "${configBean.extraParameters}"
)
public class MyBean  {
   ...
}


@ApplicationScoped
@Named
public class ConfigBean implements Serializable {
    ...
    public String getClientId() {
        return clientId;
    }
    public String getClientSecret() {
        return clientSecret;
    }
    public String[] getExtraParameters() {
        return { "audience=abc", "team=def" };
    }
}

Running this code in Wildfly 27 causes the following exception:

jakarta.enterprise.inject.spi.DefinitionException: OpenIdAuthenticationMechanismDefinition.extraParameters() value '${configBean.extraParameters}' is not of the format key=value

The question is: How can I set the extraParameters with expression language?

As you can see here there a also extra parameters defined ending with the sufix 'expression' expecting a String. But also with this param I did not found a solution to set a value with EL.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ralph
  • 4,500
  • 9
  • 48
  • 87
  • Thanks, I was not aware about this detail. I edited the question now to the @openidauthenticationmechanismdefinition. Maybe this is more an issue specific to wildfly. It is hard to find examples about the new OIDC security API of Jakarta EE. Most examples show hard coded parameters. – Ralph Jun 14 '23 at 06:38
  • After more investigation it looks to me that annotation params like `scope` or `extraParameters` can only be hard coded in `@OpenIdAuthenticationMechanismDefinition`. This means you can't write an interoperable application using different OpenID providers :-( – Ralph Jun 30 '23 at 12:03

0 Answers0