简体   繁体   中英

Play2 Framework - Scala - Silhouette check token manually

I'm using Play Framework with Scala to build a RESTful API. To implement authentication I'm using the play-silhouette plugin, with the use of a BearerTokenAuthenticator . It works perfectly.

The problem is that I must implement a service that use a WebSocket to push real-time updates, but I can't manage to setup user authentication for this method.

Silhouette provides support to do that ( doc ), the problem is that I can't find a way to put the token in the header of the websocket handshake requests. I did a lot of research, but without any result.

I thought that I could pass the token in the query string, instead of passing it in the request header.

My question is, how can I validate a token manually with silhouette?

This is currently not possible. I've created an issue to fix this with the help of a request extractor .

In the meantime you could override the retrieve method of the BearerTokenAuthenticatorService and use the value from query string instead of the header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM