{"id":15284461,"url":"https://github.com/innfactory/akka-jwt","last_synced_at":"2026-03-12T08:35:21.883Z","repository":{"id":57730559,"uuid":"101512707","full_name":"innFactory/akka-jwt","owner":"innFactory","description":"Library for jwt authentication with akka","archived":false,"fork":false,"pushed_at":"2019-08-09T09:22:49.000Z","size":38,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-21T10:12:32.866Z","etag":null,"topics":["akka","akka-directive","auth0","authentication","cognito","jwt","nimbus","nimbusds"],"latest_commit_sha":null,"homepage":"https://innfactory.de","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/innFactory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-26T20:54:45.000Z","updated_at":"2024-10-17T20:12:21.000Z","dependencies_parsed_at":"2022-09-26T22:01:27.458Z","dependency_job_id":null,"html_url":"https://github.com/innFactory/akka-jwt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innFactory%2Fakka-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innFactory%2Fakka-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innFactory%2Fakka-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/innFactory%2Fakka-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/innFactory","download_url":"https://codeload.github.com/innFactory/akka-jwt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240176097,"owners_count":19760297,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["akka","akka-directive","auth0","authentication","cognito","jwt","nimbus","nimbusds"],"created_at":"2024-09-30T14:57:06.492Z","updated_at":"2026-03-12T08:35:21.817Z","avatar_url":"https://github.com/innFactory.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# akka-jwt\n[![travis-ci.org](https://travis-ci.org/innFactory/akka-jwt.svg?branch=master)](https://travis-ci.org/innFactory/akka-jwt)\n[![codecov.io](https://img.shields.io/codecov/c/github/innFactory/akka-jwt/master.svg?style=flat)](https://codecov.io/github/innFactory/akka-jwt)\n[![shields.io](http://img.shields.io/badge/license-Apache2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n[ ![Download](https://api.bintray.com/packages/innfactory/sbt-plugins/akka-jwt/images/download.svg) ](https://bintray.com/innfactory/sbt-plugins/akka-jwt/_latestVersion)\n\nLibrary for jwt authentication with akka\n\n\n## Information\nThis library provides you an akka directive for your route to authenticate your user with jwt. the jwt implementation adapts nimbus JOSE + JWT.\n\n### Changelog\n\n#### 1.2.0\n\n#### 1.0.0\n- Initial Release\n\n### Setup\n```scala\nlibraryDependencies += \"de.innFactory\" %% \"akka-jwt\" % \"1.2.0\"\n```\n\nAfter that you must extend your akka-http Route with ```JwtAuthDirectives```. Then just implement a AuthService ```protected val authService: AuthService```\n\nAfter that you can build your route like this: \n\n```scala\nval route: Route =\n    (post \u0026 path(\"graphql\")) {\n      authenticate { credentials =\u003e\n        entity(as[JsValue]) { requestJson ⇒\n```\n\nyou 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.\n\n## Validator API\n\nThe 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!\n\n```\nfinal case class JwtToken(content: String) extends AnyVal\n\ntrait JwtValidator {\n  def validate(jwtToken: JwtToken): Either[BadJWTException, (JwtToken, JWTClaimsSet)]\n}\n```\n\n### Available `JwtValidator` implementations\n\n#### 1. ConfigurableJwtValidator\n\nThe more flexible implementation of the `JwtValidator` interface.\n\nIt only requires a `JWKSource` instance.    \nFor 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\n\nExample of use:\n```scala\nval token: JwtToken = JwtToken(content = \"...\")\n\nval jwkSet: JWKSource[SecurityContext] = new RemoteJWKSet(new URL(s\"https://your.jwks.prodvider.example.com/.well-known/jwks.json\"))\nval validator =  ConfigurableJwtValidator(jwkSet)\n```\n\nFor more information on JWKs, you could read:   \n  - Auth0 doc: https://auth0.com/docs/jwks    \n  - Nimbus doc: https://connect2id.com/products/server/docs/api/jwk-set       \n  - AWS Cognito doc: https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html#amazon-cognito-identity-user-pools-using-id-and-access-tokens-in-web-api\n\nOther constructor parameters are:\n\n  - `maybeCtx: Option[SecurityContext] = None`   \n    (Optional) Security context.    \n    Default is `null` (no Security Context).\n    \n  - `additionalChecks: List[(JWTClaimsSet, SecurityContext) =\u003e Option[BadJWTException]] = List.empty`   \n    (Optional) List of additional checks that will be executed on the JWT token passed.    \n    Default is an empty List.\n    \n    Some \"additional checks\" are already implemented in the object `ProvidedAdditionalChelcks`.\n\n#### 2. AwsCognitoJwtValidator\n\nExample of use:\n```scala\nval awsRegion = AWSRegion(AWSRegions.Frankfurt)\nval cognitoUserPoolId = CognitoUserPoolId(value = \"...\")\n\nval awsCognitoJwtValidator = AwsCognitoJwtValidator(awsRegion, cognitoUserPoolId)\n```\n\nNeed a token generator for aws? Look at\n\nhttps://innfactory.de/de/blog/34-software-engineering/52-javascript-desktop-app-electron\nhttps://github.com/innFactory/aws-session-token-gui\n\n\n## Copyright \u0026 Contributers\n\n* Tobias Jonas\n* Jules Ivanic \n\nCopyright (C) 2019 [innFactory Cloud- \u0026 DataEngineering](https://innFactory.de)\n\nPublished under the Apache 2 License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnfactory%2Fakka-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finnfactory%2Fakka-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finnfactory%2Fakka-jwt/lists"}