Skip to content
This repository has been archived by the owner on Sep 12, 2021. It is now read-only.

Commit

Permalink
Move silhouette traits to different file
Browse files Browse the repository at this point in the history
  • Loading branch information
wsargent committed Jan 16, 2020
1 parent 2a25d60 commit 3b1633f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
13 changes: 0 additions & 13 deletions app/controllers/MyRequest.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
*/
Expand Down
30 changes: 30 additions & 0 deletions app/controllers/SilhouetteTraits.scala
Original file line number Diff line number Diff line change
@@ -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]

0 comments on commit 3b1633f

Please sign in to comment.