Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

guardian/editorial-permissions-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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("user.email@guardian.co.uk")

  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:

About

Client library for accessing the permissions data across editorial tools.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages