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

Can you please provide the example on how to use authorization? #5

Open
michalig opened this issue Mar 14, 2018 · 1 comment
Open

Comments

@michalig
Copy link

Hi,

I'm trying to send message to a single user (with convertAndSendToUser) and I'm not sure how to do it properly... I'm trying with STOMP authentication - by overriding configureClientInboundChannel in AbstractWebSocketMessageBrokerConfigurer with:

@Override
    public void configureClientInboundChannel(ChannelRegistration registration) {
        registration.setInterceptors(new ChannelInterceptorAdapter() {
            @Override
            public Message<?> preSend(Message<?> message, MessageChannel channel) {
                StompHeaderAccessor accessor =
                        MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
                if (StompCommand.CONNECT.equals(accessor.getCommand())) {
                    Principal userDetails = new UserDetails("userId#1");
                    accessor.setUser(userDetails);
                }
                return message;
            }
        });
    }

But I'm still getting no Principal object in ProxyWebSocketConnectionManager#handleFrame

Any clues?

Cheers,
Michal

@woostju
Copy link

woostju commented Aug 28, 2018

Need to pass the Principal from zuul to backend microservice.
put the sessionid into headers in method ProxyWebSocketConnectionManager#buildWebSocketHttpHeaders.
Then in backend microservice HandshakeInterceptor, get the session id thru servletRequest.getServletRequest().getHeader("session_id"), and set this session id as Principal.

Also use this session id as principal at zuul side, with HandshakeHandler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants