-
Notifications
You must be signed in to change notification settings - Fork 141
Make SecuredRequest and UserAwareRequest traits #574
Conversation
b05c067
to
19b55b8
Compare
19b55b8
to
a00e861
Compare
Do you have a concrete example for this? The |
@akkie created mohiva/play-silhouette-seed#118 as a concrete example |
So the issue is more about being able to expose
or for a username fragment (for example in the navbar):
Thinking about it a bit more, this could be broken down more into trait SecuredMessagesHeader extends IdentityProvider with AuthenticatorProvider And then the twirl code wouldn't have to be tied directly to the request:
|
I think the only thing that could probably break current code is the ability to pattern match against the current implementation. So I think this pull request needs an unapply method too in the companion object. |
Sorry, I'm lost. What companion object are we talking about? Both |
Yes, I meant both companion objects. In the old implementation both request types were case classes, which a user could pattern match on. Currently this isn't possible. I'm not sure it's really a use case to pattern match on the request types. What do you think? |
Can't hurt, I'll add it. |
Done. I see a failure on higher kinded types, not sure about touching the CI build system though. |
Thanks Will 👍 |
Purpose
This PR changes
SecuredRequest
from a case class to a trait, and adds aSecuredRequestHeader
trait as well.This makes it easier to change the implementation of a secured request because a wrapped request may want to implement secured request behavior, i.e. the identity and authenticator, but cannot because there is not a trait for it.
Because there is a factory method which uses the default impl behind the scenes, this should have no impact on user facing code (although I have not tried binary compatibility, etc.)
Background Context
This is the approach used for extending Play requests internally, i.e. in https://github.com/playframework/playframework/blob/2.6.x/core/play/src/main/scala/play/api/mvc/MessagesRequest.scala
Note that the request body should be covariant per playframework/playframework#8240