There are examples for using multiple types of Authenticators in the same Play Framework application BUT the one I am after is, using 2 JWT authenticators where they have different headerNames, issuer claims and crypter using separate Silhouette environments for each inside the same application.
Update: I have created 2 environments for Silhouette but both signatures are same with different name only, as follows:
trait DefaultEnv extends Env {
type I = User
type A = JWTAuthenticator
}
trait CustomEnv extends Env {
type I = User
type A = JWTAuthenticator
}
MyModule extends AbstractModule with ScalaModule {
...
@Provides
def provideAuthenticatorService(crypter: Crypter,
idGenerator: IDGenerator,
configuration: Configuration,
clock: Clock): AuthenticatorService[JWTAuthenticator] = {
val encoder = new CrypterAuthenticatorEncoder(crypter)
new JWTAuthenticatorService(JWTAuthenticatorSettings(
fieldName = configuration.underlying.getString("silhouette.authenticator.headerName"),
issuerClaim = configuration.underlying.getString("silhouette.authenticator.issuerClaim"),
authenticatorExpiry = FiniteDuration(configuration.underlying.getLong("silhouette.authenticator.authenticatorExpiry"), "seconds"),
sharedSecret = configuration.underlying.getString("application.secret")
), None, encoder, idGenerator, clock)
}
}
This actually provides the same AuthenticatorService
, how to provide different AuthenticatorService
for different named environment while they both are actually AuthenticatorService[JWTAuthenticator]
?