guardian / editorial-permissions-client   0.1.1

GitHub

Client library for accessing the permissions data across editorial tools.

Scala versions: 2.12 2.11 2.10

editorial-permissions-client

NB: the client library has been moved to the main Permission code-base. Please make any further updates there. https://github.com/guardian/permissions

Scala Client library for the Guardian's Editorial Permissions service.

Usage

Add the following dependency to your build.sbt

libraryDependencies += "com.gu" %% "editorial-permissions-client" % "0.2"

Then mixin the PermissionsProvider trait to configure integration with PermissionsConfig and all your application Permissions by defining val all: Seq[Permission].

For example:

import com.gu.editorial.permissions.client._

import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

object MyPermissions extends PermissionsProvider {
  val app = "composer"

  implicit def config = PermissionsConfig(
    app = app,
    all = all
  )

  val LaunchContent = Permission("launch_content", app, PermissionGranted)

  val all = Seq(LaunchContent)
}

object Example {

  implicit def permissionsUser: PermissionsUser =
    PermissionsUser("[email protected]")

  MyPermissions.get(MyPermissions.LaunchContent).map {
    case PermissionGranted => "I'm in!"
    case PermissionDenied => ":("
  }

  val myPerms: Future[PermissionsMap] = MyPermissions.list
}

Contributing

Releasing

Ensure tests pass before a release.

sbt clean test

Then release using:

sbt release

Note you will need: