Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 1.51 KB

File metadata and controls

44 lines (35 loc) · 1.51 KB

MAuth Authenticator Using Akka Http

This is an implementation of Medidata Authentication Client Authenticator to validate the Http requests

Usage

  1. Configuration

    • MAuth uses Typesafe Config. The v2_only_authenticate flag can be set to authenticate incoming requests with Mauth protocol V2 only, default to false. Create application.conf on your classpath with following content.

app {
    uuid: "aaaa-bbbbb-ccccc-ddddd-eeeee"
    private_key: "avasdfasdfadf"
}

mauth {
    base_url: "http://localhost"
}
  1. To validate (authenticate) incoming requests, e.g. (using Servlet Filter):

class MyController extends MAuthDirectives {
    final Config typeSafeConfig = ConfigFactory.load();
    val singerConfiguration = new SignerConfiguration(typeSafeConfig);
    val authConfig = new AuthenticatorConfiguration(typeSafeConfig);

    implicit val system: ActorSystem = ActorSystem()
    implicit val publicKeyProvider: ClientPublicKeyProvider = new MauthPublicKeyProvider(authConfig, MAuthRequestSigner(singerConfiguration))
    implicit val timeout: FiniteDuration = 10.seconds
    implicit val requestValidationTimeout: Duration = authConfig.getTimeToLive.seconds
    implicit val authenticator: RequestAuthenticator = new RequestAuthenticator(publicKeyProvider, new CurrentEpochTimeProvider, authConfig.isV2OnlyAuthenticate)

    def getResource = authenticate.apply {
        get {
            path("resources") {
                complete("OK")
            }
        }
    }
}