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

An implementation of the Silhouette persistence layer using ReactiveMongo

License

Notifications You must be signed in to change notification settings

mohiva/play-silhouette-persistence-reactivemongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Silhouette Persistence ReactiveMongo Maven Central Build Status Coverage Status Gitter

An implementation of the Silhouette persistence layer using ReactiveMongo.

Usage

In your project/Build.scala:

libraryDependencies ++= Seq(
  "com.mohiva" %% "play-silhouette-persistence-reactivemongo" % "5.0.6"
)

An instance of the DAO can be created as follow:

implicit lazy val format = Json.format[OAuth1Info]
val dao = new MongoAuthInfoDAO[OAuth1Info](reactiveMongoApi, config)

The Json format is needed to serialize the auth info data into Json. It will be passed implicitly to the DAO instance. The ReactiveMongo API and the Play configuration instance should be provided through dependency injection.

To provide bindings for Guice, you should implement a provider for every auth info type:

/**
 * Provides the implementation of the delegable OAuth1 auth info DAO.
 *
 * @param reactiveMongoApi The ReactiveMongo API.
 * @param config The Play configuration.
 * @return The implementation of the delegable OAuth1 auth info DAO.
 */
@Provides
def provideOAuth1InfoDAO(reactiveMongoApi: ReactiveMongoApi, config: Configuration): DelegableAuthInfoDAO[OAuth1Info] = {
  implicit lazy val format = Json.format[OAuth1Info]
  new MongoAuthInfoDAO[OAuth1Info](reactiveMongoApi, config)
}

Configuration

To define the collection name under which the auth info data should be saved, you must provide a configuration setting in the form silhouette.persistence.reactivemongo.collection.[AuthInfo].

As example:

silhouette {
  persistence.reactivemongo.collection.OAuth1Info = "auth.info.oauth1"
  persistence.reactivemongo.collection.OAuth2Info = "auth.info.oauth2"
  persistence.reactivemongo.collection.OpenIDInfo = "auth.info.oauth1"
  persistence.reactivemongo.collection.PasswordInfo = "auth.info.passwords"
}

If no configuration can be found, then the DAO uses automatically the name of the auth info class prefixed with auth.. So for the OAuth1Info type, it uses the collection name auth.OAuth1Info.

License

The code is licensed under Apache License v2.0 and the documentation under CC BY 3.0.

About

An implementation of the Silhouette persistence layer using ReactiveMongo

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •