Package

com.lookout

borderpatrol

Permalink

package borderpatrol

This is the root package of borderpatrol-core which provides a functional approach to web sessions and authentication built on top of Finagle. It contains two main packages: com.lookout.borderpatrol.sessionx and com.lookout.borderpatrol.auth which contain types and functions to interact with HTTP services.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. borderpatrol
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class AnyOps[A] extends AnyVal

    Permalink

    Wraps any object with a toFuture method

    Wraps any object with a toFuture method

    A

    object type

  2. case class BpCommunicationError(error: String) extends BpCoreError with Product with Serializable

    Permalink
  3. class BpCoreError extends Exception

    Permalink
  4. case class CustomerIdentifier(subdomain: String, defaultServiceId: ServiceIdentifier, loginManager: LoginManager) extends Product with Serializable

    Permalink

    An identifier for Border Patrol to determine by subdomain which service a request should be routed to

  5. trait HealthCheck extends AnyRef

    Permalink

    Derive a custom healthCheck from this trait and register with the registry

  6. class HealthCheckRegistry extends AnyRef

    Permalink
  7. case class HealthCheckStatus(status: Status, messageStr: Option[String] = None, messageJson: Option[Json] = None) extends Product with Serializable

    Permalink

    Health Check status

    Health Check status

    messageStr

    Message in string format

    messageJson

    Message in JSON format

  8. implicit final class IdxByteSeqOps extends AnyVal

    Permalink
  9. case class InternalAuthProtoManager(name: String, loginConfirm: Path, authorizePath: Path) extends ProtoManager with Product with Serializable

    Permalink

    Internal authentication, that merely redirects user to internal service that does the authentication

    Internal authentication, that merely redirects user to internal service that does the authentication

    name

    name of the proto manager

    loginConfirm

    path intercepted by bordetpatrol and internal authentication service posts the authentication response on this path

    authorizePath

    path of the internal authentication service where client is redirected

  10. case class LoginManager(name: String, identityManager: Manager, accessManager: Manager, protoManager: ProtoManager) extends Product with Serializable

    Permalink

    Login Manager defines various collections of the identity manager, access manager and proto manager.

    Login Manager defines various collections of the identity manager, access manager and proto manager. The customerIdentifier configuration picks the login manager appropriate for their cloud.

    name

    name of the login manager

    identityManager

    identity manager used by the given login manager

    accessManager

    access manager

    protoManager

    protocol used by the login manager

  11. case class Manager(name: String, path: Path, hosts: Set[URL]) extends Product with Serializable

    Permalink

    Manager represents upstream access and identity managers

    Manager represents upstream access and identity managers

    name

    name of the manager

    path

    path to the manager

    hosts

    endpoints for the manager

  12. case class OAuth2CodeProtoManager(name: String, loginConfirm: Path, authorizeUrl: URL, tokenUrl: URL, certificateUrl: URL, clientId: String, clientSecret: String) extends ProtoManager with Product with Serializable

    Permalink

    OAuth code framework, that redirects user to OAuth2 server.

    OAuth code framework, that redirects user to OAuth2 server.

    name

    name of the proto manager

    loginConfirm

    path intercepted by borderpatrol and OAuth2 server posts the oAuth2 code on this path

    authorizeUrl

    URL of the OAuth2 service where client is redirected for authenticaiton

    tokenUrl

    URL of the OAuth2 server to convert OAuth2 code to OAuth2 token

    certificateUrl

    URL of the OAuth2 server to fetch the certificate for verifying token signature

    clientId

    Id used for communicating with OAuth2 server

    clientSecret

    Secret used for communicating with OAuth2 server

  13. trait ProtoManager extends AnyRef

    Permalink

    ProtoManager defines parameters specific to the protocol

  14. case class ServiceIdentifier(name: String, hosts: Set[URL], path: Path, rewritePath: Option[Path], protekted: Boolean) extends Product with Serializable

    Permalink

    An identifier for Border Patrol to determine by path which service a request should be routed to

    An identifier for Border Patrol to determine by path which service a request should be routed to

    name

    The name that can be used to refer to a com.twitter.finagle.Name

    hosts

    The list of URLs to upstream service

    path

    The external url path prefix that routes to the internal service

    rewritePath

    The (optional) internal url path prefix to the internal service. If present, it replaces the external path in the Request URI

    protekted

    The service is protected or unprotected (i.e. does not go through access issuer)

  15. case class ServiceMatcher(customerIds: Set[CustomerIdentifier], serviceIds: Set[ServiceIdentifier]) extends Product with Serializable

    Permalink
  16. implicit final class StringOps extends AnyVal

    Permalink
  17. implicit final class ThrowableOps extends AnyVal

    Permalink

    Wraps any Throwable with a toFutureException method

  18. trait Transform[A, B] extends AnyRef

    Permalink

    Abstraction for those that are directing requests directly to the Identity Provider

Value Members

  1. object Binder

    Permalink

    Binder object defines methods and shells used to bind to upstream endpoints

  2. object BinderBase

    Permalink
  3. object HealthCheck

    Permalink
  4. object HealthCheckStatus extends Serializable

    Permalink
  5. package auth

    Permalink

    This provides the specification contracts for doing auth in the form of Type Classes in auth.Access and auth.Identity

    This provides the specification contracts for doing auth in the form of Type Classes in auth.Access and auth.Identity

    Taking SAML 2.0 and OAuth2 as example flows, we have defined a set of contracts and abstractions on those contracts to allow users of this library to implement instances of their specific authentication/authorization.

    The flow for a typical SAML/OAuth2 involves a protected resource, a client (web browser), and an Identity Provider. Border Patrol can act as a translation layer for external representation of access and internal representation so that services behind it do not need to implement SAML/OAuth2.

    The primary abstractions are:

    • Identity the external identity provider and types, e.g. SAML IdP
    • Access the internal access provider and types, e.g. api tokens, jwt etc
  6. package crypto

    Permalink

    The crypto module includes primitives for:

    The crypto module includes primitives for:

    It also includes Type Classes for interfacing with backends that would like to encrypt data at rest.

  7. object errors

    Permalink
  8. object request

    Permalink
  9. package sessionx

    Permalink

    This introduces types and functions that enable identifying, fetching, and storing web session data.

    This introduces types and functions that enable identifying, fetching, and storing web session data. This is accomplished by a set of types that will be used by consumers of this library: Session, Store, and Secret.

    A Secret is a cryptographically verifiable signing key used to sign a SignedId. Creating a Secret is simple. It defaults to expire at Secret.lifetime

    val secret = Secret() // default secret expiry
    val expiringSecret = Secret(Time.now)
    
    val randomBytes = EntropyGenerator(16) // 16 bytes of randomness
    val randomId = EntropyGenerator(1).head // 1 byte of randomness for an id
    val expiry = Time.from(0) // very expired
    val constructedSecret = Secret(randomId, randomBytes, expiry)
    log(s"secret has expired: ${constructedSecret.expired == true}")
    
    val signedMsg = secret.sign("message to by signed".getBytes)

    A SignedId is a cryptographically signed identifier for a Session, it consists of entropy, expiry, secret,and signature of those items. This is meant to be used as the com.twitter.finagle.http.Cookie value, so we provide serializing to String.

    val id: SignedId = Await.result(SignedId.next)
    val cookieValue: String = id.asBase64
    SignedId.from[String](cookieValue) == id

    A Session is product type of a cryptographically verifiable identifier SignedId and an arbitrary data type A. The only requirement for a SessionStore[B,M] to store/fetch a Session[A] is that there be some implicit injective views from A => B and B => Try[A].

    We have provided default encodings for: http.Request => Buf, String => Buf and their injective views.

    // set up secret/session stores
    implicit val secretStore = SecretStores.InMemorySecretStore(Secrets(Secret(), Secret()))
    val sessionStore = SessionStore.InMemoryStore()
    
    // create a Session[http.Request]
    val newSessionFuture = Session(Request("http://localhost/api/stuff")) // entropy is blocking on the JVM
    val newSession = Await.result(newSessionFuture)
    
    // see if the session expired (checks the [[SignedId.expires]])
    log(s"Session has expired? ${newSession.expired}")
    
    // store the session and then fetch it
    sessionStore.update(newSession).onFailure(log)
    sessionStore.get(newSession.id).onSuccess(s => s match {
      case Some(s) => log(s"Same session?: ${newSession == s}")
      case None => log("hrm, where did the session go?")
    })

    Let's say you have a Session.data type that doesn't have the injective that you need, that's OK! Assuming you are storing it in memcached, which requires a type of Buf for the value:

    trait Foo {
      val value: Int
    }
    
    implicit val enc = SessionDataEncoder[Foo](
      foo => Buf.U32BE(foo.value),
      buf => new Foo { override val value = Buf.U32BE.unapply(buf) }
    )
    
    val foo1 = new Foo { override val value = 1 }
    val fooSession = Session(foo1)
    sessionStore.update(fooSession)
  10. package util

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped