Andrea Cosentino created CAMEL-26879:
----------------------------------------

             Summary: camel-keycloak, camel-shiro - add the security policy 
beans to the bean catalog
                 Key: CAMEL-26879
                 URL: https://issues.apache.org/jira/browse/CAMEL-26879
             Project: Camel
          Issue Type: Improvement
          Components: camel-keycloak, camel-shiro
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.24.0


Follow-up of CAMEL-26559, which added {{OpaSecurityPolicy}}, 
{{OpenFgaSecurityPolicy}}, {{SpiffeSecurityPolicy}} and 
{{SpiffeSSLContextParameters}} to the bean catalog and left the other security 
policies out.

h4. What happens

{{KeycloakSecurityPolicy}} and {{ShiroSecurityPolicy}} have no bean entry in 
the catalog either, so {{camel run}} cannot find their jar when a YAML route 
declares one under {{beans:}}:

{code:yaml}
- beans:
    - name: keycloakPolicy
      type: org.apache.camel.component.keycloak.security.KeycloakSecurityPolicy
      properties:
        serverUrl: http://localhost:8080
        realm: camel
        clientId: camel-client
        requiredRoles: admin
- route:
    from:
      uri: timer:tick?repeatCount=1
      steps:
        - policy:
            ref: keycloakPolicy
            steps:
              - log: "allowed"
{code}

{noformat}
$ camel run policy.yaml --camel-version=4.23.0
Caused by: java.lang.ClassNotFoundException: 
org.apache.camel.component.keycloak.security.KeycloakSecurityPolicy
{noformat}

The same with {{ShiroSecurityPolicy}}. It works with {{--dep=camel:keycloak}} 
or {{--dep=camel:shiro}}. As explained on CAMEL-26559, YAML beans are created 
while the file is pre-parsed, and {{camel run}} finds the jar of a missing bean 
class only through the known dependencies (component classes only) or the 
catalog's pojo-bean metadata.

h4. Proposed fix

The same as CAMEL-26559: {{@Metadata(label = "bean", ...)}} and 
{{@Configurer(metadataOnly = true)}} on the two classes, and {{@Metadata}} on 
each option, so the catalog carries their Maven coordinates and documents their 
options. Both already keep their options in fields. {{ShiroSecurityPolicy}} 
takes its INI resource as a constructor argument, which a YAML bean passes with 
{{constructors:}}; its description should say so.

_Claude Code on behalf of oscerd_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to