diff --git a/app/controllers/MyRequest.scala b/app/controllers/MyRequest.scala index f306bbd..78ec4f8 100644 --- a/app/controllers/MyRequest.scala +++ b/app/controllers/MyRequest.scala @@ -1,6 +1,5 @@ package controllers -import com.mohiva.play.silhouette.api.Env import org.slf4j.Marker import play.api.MarkerContext import play.api.i18n.MessagesApi @@ -10,18 +9,6 @@ import utils.auth.DefaultEnv import scala.concurrent.{ExecutionContext, Future} import scala.language.higherKinds -// XXX should be OOTB -trait SecuredRequestHeader[E <: Env] { - def identity: E#I - def authenticator: E#A -} - -// XXX should be OOTB -trait UserAwareRequestHeader[E <: Env] { - def identity: Option[E#I] - def authenticator: Option[E#A] -} - /** * Defines our own request with extended features above and beyond what Silhouette provides. */ diff --git a/app/controllers/SilhouetteTraits.scala b/app/controllers/SilhouetteTraits.scala new file mode 100644 index 0000000..3d665b1 --- /dev/null +++ b/app/controllers/SilhouetteTraits.scala @@ -0,0 +1,30 @@ +package controllers + +import com.mohiva.play.silhouette.api.{Authenticator, Env, Identity} +import play.api.mvc.RequestHeader + +trait IdentityProvider[I <: Identity] { + def identity: I +} + +trait AuthenticatorProvider[A <: Authenticator] { + def authenticator: A +} + +// XXX should be OOTB +trait SecuredRequestHeader[E <: Env] extends RequestHeader + with IdentityProvider[E#I] + with AuthenticatorProvider[E#A] + +trait IdentityAwareProvider[I <: Identity] { + def identity: Option[I] +} + +trait AuthenticatorAwareProvider[A <: Authenticator] { + def authenticator: Option[A] +} + +// XXX should be OOTB +trait UserAwareRequestHeader[E <: Env] extends RequestHeader + with IdentityAwareProvider[E#I] + with AuthenticatorAwareProvider[E#A]