Git Product home page Git Product logo

gravitee-policy-jws's Introduction

JWS validator policy

Gravitee.io License Releases CircleCI

Phase

onRequest onResponse

X

Description

You can use the jws-validator policy to validate the JWS token signature, certificate information and expiration date before sending the API call to the target backend.

JWT in JWS format enables secure content to be shared across security domains. The RFC standards are as follows:

JWT

A JWT is composed of three parts: a header, a payload and a signature. You can see some examples here: http://jwt.io.

  • The header contains attributes indicating the algorithm used to sign the token.

  • The payload contains some information inserted by the AS (Authorization Server), such as the expiration date and UID of the user.

Both the header and payload are encoded with Base64, so anyone can read the content.

  • The third and last part is the signature (for more details, see the RFC).

Input

======================= =================================================
Request Method          POST
Request Content-Type    application/jose+json
Request Body            eyJ0....ifQ.eyJzdWIiOiI...lIiwiYWRtaW4iOnRydWV9.TJVA95...h7HgQ
Response Codes          Backend response or 401 Unauthorized
======================= =================================================

According to the JWS RFC, the JWT/JWS header must contain the following information if correct content is to be provided to the backend:

A typ value of JOSE can be used by applications to indicate that this object is a JWS or JWE using JWS Compact Serialization or the JWE Compact Serialization. A typ value of JOSE+JSON can be used by applications to indicate that this object is a JWS or JWE using JWS JSON Serialization or JWE JSON Serialization.

The cty (content type) header parameter is used by JWS applications to declare the media type [IANA.MediaTypes] of the secured content (the payload). To keep messages compact in typical scenarios, it is strongly recommended that senders omit the application/ prefix of a media type value in a cty header parameter when no other / appears in the media type value.

Note
A recipient using the media type value must treat it as if application/ were prepended to any cty value not containing a /.

Example

A valid example of a JWS header is as follows:

{
 "typ":"JOSE+JSON",
 "cty":"json",
 "alg":"RS256",
 "x5c":"string",
 "kid":"string"
}

Configuration

Property Required Description Type Default

checkCertificateValidity

Check if the certificate used to sign the JWT is correct and has valid not_before and not_after dates

boolean

false

checkCertificateRevocation

Check if the certificate used to sign the JWT is not revoked via the CRL Distribution Points. The CRL is stored inside the X509v3 CRL Distribution Extension Points.

boolean

false

To validate the token signature, the policy needs to use the JWS validator policy public key set in the APIM Gateway gravitee.yml file:

policy:
  jws:
    kid:
      default: ssh-rsa myValidationKey [email protected]
      kid-2016: /filepath/to/pemFile/certificate.pem

The policy will inspect the JWT/JWS header to extract the key id (kid attribute) of the public key. If no key id is found then it is set to default.

The gateway will be able to retrieve the corresponding public key and the JOSE Header using x5c (X.509 Certificate Chain). The header parameter will be used to verify certificate information and check that the JWT was signed using the private key corresponding to the specified public key.

Errors

HTTP status code

Code Message

401

Bad token format, content, signature, certificate, expired token or any other issue preventing the policy from validating the token

gravitee-policy-jws's People

Contributors

a-cordier avatar aelamrani avatar brasseld avatar gcusnieux avatar graviteeio avatar intrigus avatar phiz71 avatar plsstephenson avatar snyk-bot avatar tcompiegne avatar thibaudav avatar ytvnr avatar

Watchers

 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.