Silhouette

Migration Guide

This is a guide for migrating from Silhouette 5.0 to Silhouette 6.0

The new Silhouette 6.0 version depends on Play 2.7. So please visit the Play 2.7 Migration Guide for more information.

Info

If you migrate from version 4.0 to 5.0 please refer to the 5.0 migration guide.

DelegableAuthInfoDAO

The DelegableAuthInfoDAO is now a trait instead of an abstract class. The issue was, that the abstract class couldn't be inherited from another abstract class.

Previously the abstract class has defined the needed ClassTag as implicit constructor parameter. This must now be defined by the concrete implementation.

class InMemoryAuthInfoDAO[T <: AuthInfo](implicit val classTag: ClassTag[T]) 
  extends DelegableAuthInfoDAO[T] { ... }

For a specific type, an implementation may look like:

class PasswordDAO @Inject (
  protected val db: Database
)(
  implicit
  val classTag: ClassTag[PasswordInfo]
)  extends DelegableAuthInfoDAO[PasswordInfo] { ... }

Instantiate such a class with Guice

For the first case, we can instantiate the class with the following statement. This is possible because the class InMemoryAuthInfoDAO has no constructor parameters other than the implicit ClassTag.

bind[DelegableAuthInfoDAO[PasswordInfo]]
  .toInstance(new InMemoryAuthInfoDAO[PasswordInfo])

If a class has additional constructor parameters, then the last statement won't work. Instead we must use a Guice @Provides annotated method which gives us the needed constructor parameters to instantiate the class.

@Provides
def providePasswordDAO(db: Database): DelegableAuthInfoDAO[PasswordInfo] = new PasswordDAO(db)

In both cases, the compiler will add the ClassTag automatically.

Updated 3 months ago

Migration Guide


This is a guide for migrating from Silhouette 5.0 to Silhouette 6.0

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.