All Projects → innFactory → akka-jwt

innFactory / akka-jwt

Licence: Apache-2.0 license
Library for jwt authentication with akka

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to akka-jwt

akka-stream-kafka-template.g8
Template for Akka Streams & Kafka. Default impl: mirror a topic onto another one
Stars: ✭ 14 (-12.5%)
Mutual labels:  akka
akka-pusher
Pusher meets Akka
Stars: ✭ 18 (+12.5%)
Mutual labels:  akka
aws-cloudformation-cognito-identity-pool
A Lambda-backed Custom Resource for a Cognito Identity Pool in CloudFormation
Stars: ✭ 35 (+118.75%)
Mutual labels:  cognito
cypress-nextjs-auth0
Cypress commands to support Auth0 and Next.js
Stars: ✭ 56 (+250%)
Mutual labels:  auth0
serverless-stack-demo-user-mgmt-client
Source for demo app client with user management in Serverless-Stack.com
Stars: ✭ 41 (+156.25%)
Mutual labels:  cognito
khermes
A distributed fake data generator based in Akka.
Stars: ✭ 94 (+487.5%)
Mutual labels:  akka
akka-stream-mon
Throughput and latency monitoring for Akka Streams
Stars: ✭ 23 (+43.75%)
Mutual labels:  akka
aws-cognito-app
A sample application that uses the AWS PHP SDK to implement AWS Cognito functionality
Stars: ✭ 89 (+456.25%)
Mutual labels:  cognito
alpakka-samples
Example projects building Reactive Integrations using Alpakka
Stars: ✭ 61 (+281.25%)
Mutual labels:  akka
akka-ui
AkkaUI - Build your reactive UI using Akka.js
Stars: ✭ 55 (+243.75%)
Mutual labels:  akka
slicebox
Microservice for safe sharing and easy access to medical images
Stars: ✭ 18 (+12.5%)
Mutual labels:  akka
dokugaku-engineer
独学エンジニア
Stars: ✭ 184 (+1050%)
Mutual labels:  auth0
scala-akka
OpenTracing instrumentation for Scala Akka
Stars: ✭ 16 (+0%)
Mutual labels:  akka
akka-cookbook
提供清晰、实用的Akka应用指导
Stars: ✭ 30 (+87.5%)
Mutual labels:  akka
cognito-to-dynamodb-lambda
Copy newly-confirmed users from Cognito to DynamoDB
Stars: ✭ 68 (+325%)
Mutual labels:  cognito
auth0-aspnetcore-mvc-samples
Auth0 Integration Samples for ASP.NET Core MVC Web Applications
Stars: ✭ 120 (+650%)
Mutual labels:  auth0
graphql-sample-apps
This repository contains sample GraphQL applications powered by Dgraph.
Stars: ✭ 65 (+306.25%)
Mutual labels:  auth0
akka-persistence-gcp-datastore
akka-persistence-gcp-datastore is a journal and snapshot store plugin for akka-persistence using google cloud firestore in datastore mode.
Stars: ✭ 18 (+12.5%)
Mutual labels:  akka
akka-doc-ja
Akka Japanese Documentation
Stars: ✭ 25 (+56.25%)
Mutual labels:  akka
auth0-vue
A simple Vue.js Demo Application that uses Auth0 for Authentication
Stars: ✭ 39 (+143.75%)
Mutual labels:  auth0

akka-jwt

travis-ci.org codecov.io shields.io Download

Library for jwt authentication with akka

Information

This library provides you an akka directive for your route to authenticate your user with jwt. the jwt implementation adapts nimbus JOSE + JWT.

Changelog

1.2.0

1.0.0

  • Initial Release

Setup

libraryDependencies += "de.innFactory" %% "akka-jwt" % "1.2.0"

After that you must extend your akka-http Route with JwtAuthDirectives. Then just implement a AuthService protected val authService: AuthService

After that you can build your route like this:

val route: Route =
    (post & path("graphql")) {
      authenticate { credentials =>
        entity(as[JsValue]) { requestJson 

you see, that you got a new authenticate directive for your route. It extracts the Authentication value from your header and checks it against your jwt validator.

Validator API

The Validator API has just one method validate, so you can implement your own Validators and use it for your akka Directive. AWS and the generic one were made by guizmaii. Thanks for that!

final case class JwtToken(content: String) extends AnyVal

trait JwtValidator {
  def validate(jwtToken: JwtToken): Either[BadJWTException, (JwtToken, JWTClaimsSet)]
}

Available JwtValidator implementations

1. ConfigurableJwtValidator

The more flexible implementation of the JwtValidator interface.

It only requires a JWKSource instance.
For more information on the different JWKSource implementations Nimbus provides, look at the classes in the com.nimbusds.jose.jwk.source package here: https://www.javadoc.io/doc/com.nimbusds/nimbus-jose-jwt

Example of use:

val token: JwtToken = JwtToken(content = "...")

val jwkSet: JWKSource[SecurityContext] = new RemoteJWKSet(new URL(s"https://your.jwks.prodvider.example.com/.well-known/jwks.json"))
val validator =  ConfigurableJwtValidator(jwkSet)

For more information on JWKs, you could read:

Other constructor parameters are:

  • maybeCtx: Option[SecurityContext] = None
    (Optional) Security context.
    Default is null (no Security Context).

  • additionalChecks: List[(JWTClaimsSet, SecurityContext) => Option[BadJWTException]] = List.empty
    (Optional) List of additional checks that will be executed on the JWT token passed.
    Default is an empty List.

    Some "additional checks" are already implemented in the object ProvidedAdditionalChelcks.

2. AwsCognitoJwtValidator

Example of use:

val awsRegion = AWSRegion(AWSRegions.Frankfurt)
val cognitoUserPoolId = CognitoUserPoolId(value = "...")

val awsCognitoJwtValidator = AwsCognitoJwtValidator(awsRegion, cognitoUserPoolId)

Need a token generator for aws? Look at

https://innfactory.de/de/blog/34-software-engineering/52-javascript-desktop-app-electron https://github.com/innFactory/aws-session-token-gui

Copyright & Contributers

  • Tobias Jonas
  • Jules Ivanic

Copyright (C) 2019 innFactory Cloud- & DataEngineering

Published under the Apache 2 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].