Coder Social home page Coder Social logo

jose's Introduction

<script type='module' src="https://cdn.jsdelivr.net/gh/kag0/[email protected]/sauce.js">

If you're reading this, click HERE

</script>

jose

Codacy grade Travis (.com) Scaladoc Maven Central Gitter Matrix

Extensible JOSE library for Scala.

Installation

The dependency is available on Maven Central.

Usage

Pretty simple: make a key, make something to sign, sign it.

<sauce-code repo='blackdoor/jose' lang='scala' file='docs/src/black/door/jose/docs/SampleCode.scala' lines='15:36'

Selecting a JSON implementation

Currently supported JSON libraries:

To add a JSON support, just import or mix in an implementation like import black.door.jose.json.playjson.JsonSupport._.

If your preferred library isn't supported, just implement Mapper implicits (or open an issue to request they be added).

Async key resolution and validation checks

Frequently you will need to dynamically look up a new key from a keyserver based on a JWS header, or check a centralized cache to see if a token has been revoked.
This is easy to do asynchronously by implementing KeyResolver or JwtValidator.
JwtValidator is a partial function so you can easily chain both sync and async validations.
KeyResolver allows you to return an error in the event that there was a specific reason a key could not be found (perhaps a key does exist, but it's only for encryption and this token is using it for signing).

JWT validation DSL

There is a handy compile-safe DSL for JWT validation that allows you to indicate if you want to use unregistered claims, and if you want to evaluate synchronously or asynchronously. Its structure looks like this

Jwt
|__ .validate(compactJwt)
    |__ .using(keyResolver, etc...)
    |   |__ .now   // validates the JWT synchronously
    |   |__ .async // returns the validation result in a Future
    |__ .apply[UnregisteredClaims]
        |__ .using(keyResolver, etc...)
            |__ .now   // validates the JWT synchronously
            |__ .async // returns the validation result in a Future

So for example you could synchronously validate a JWT with some custom claims with

<sauce-code repo='blackdoor/jose' lang='scala' file='docs/src/black/door/jose/docs/SampleCode.scala' lines='64:77'


Not yet implemented:

  • JWK serialization partly implemented
  • JWE
  • RSA signing (RSA signature verification is supported)
  • Less common key sizes for ECDSA
  • Custom JOSE header parameters (custom JWT claims are supported)

jose's People

Contributors

nrktkt avatar scala-steward avatar khayuenkam avatar philippus avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.