Git Product home page Git Product logo

play-silhouette-persistence-reactivemongo's Introduction

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.

play-silhouette-persistence-reactivemongo's People

Contributors

akkie avatar cchantep avatar christoribeiro avatar gguan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.