The environment defines the key components needed by a Silhouette endpoint. It consists of the following components:

A configured environment is needed for every endpoint and should be provided through dependency injection. Silhouette plays well with both compile time and runtime dependency injection. You can find examples of both approaches on the example page.

An application can provide different environments for different environment types. With this it's possible to create endpoints that can handle different identitity -> authenticator combinations.

Environment type

The environment type defines the Identity and Authenticator types for an environment. It is possible to implement as many types as needed. This has the advantage that an application isn't bound only to a single Identity -> Authenticator combination.

To define a new environment type, create a new trait with the appropriate Identity and Authenticator types:

trait SessionEnv extends Env {
  type I = User
  type A = SessionAuthenticator
trait JWTEnv extends Env {
  type I = User
  type A = JWTAuthenticator

Now with this types you can create different environments:

val sessionEnv = Environment[SessionEnv](...)
val jwtEnv = Environment[JWTEnv](...)

What's Next