Skip to content
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

SecurityIdentity is not propagated to Camel route #3353

Closed
mnhlvsk opened this issue Dec 2, 2021 · 2 comments
Closed

SecurityIdentity is not propagated to Camel route #3353

mnhlvsk opened this issue Dec 2, 2021 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@mnhlvsk
Copy link

mnhlvsk commented Dec 2, 2021

Hi guys,

I'm trying to use SecurityIdentity with Quarkus Camel, but can't get it working. Always getting an exception ContextNotActiveException when I call SecurityIdentity. Could you please help me how to solve it?

application.properties:

quarkus.http.auth.basic=true
quarkus.http.auth.permission.default.paths=/*
quarkus.http.auth.permission.default.policy=authenticated
quarkus.security.users.embedded.enabled=true
quarkus.security.users.embedded.plain-text=true
quarkus.security.users.embedded.users.jdoe=p4ssw0rd
quarkus.security.users.embedded.roles.jdoe=NoRolesUser

Route:

@ApplicationScoped
public class CamelRoute extends EndpointRouteBuilder {

        @Inject
        GreetingProcessor proc;

        @Override
        public void configure() throws Exception {
            from("platform-http:/myservice")
                    .process(proc);
        }
    }

Processor:

@ApplicationScoped
public class GreetingProcessor implements Processor {

    @Inject
    SecurityIdentity identity;

    @Override
    public void process(Exchange exchange) throws Exception {
        System.out.println(identity.getPrincipal().getName());
    }
}
@jamesnetherton
Copy link
Contributor

This does indeed seem to be broken for platform-http. Even when forcefully activating the request context with @ActivateRequestContext, the SecurityIdentity details are empty.

As a workaround you can try using camel-quarkus-servlet. SecurityIdentity should then work correctly.

@jamesnetherton jamesnetherton added the bug Something isn't working label Dec 3, 2021
@jamesnetherton jamesnetherton self-assigned this Dec 7, 2021
@jamesnetherton
Copy link
Contributor

There's a change coming in Camel 3.14.0 that should help with this scenario. In the platform-http route processor you will be able to do:

QuarkusHttpUser user = exchange.getMessage().getHeader(VertxPlatformHttpConstants.AUTHENTICATED_USER, QuarkusHttpUser.class);

Then you can access the Principal on the user object.

jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Jan 4, 2022
jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Jan 4, 2022
jamesnetherton added a commit to jamesnetherton/camel-quarkus that referenced this issue Jan 4, 2022
@jamesnetherton jamesnetherton added this to the 2.7.0 milestone Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants