Code Monkey home page Code Monkey logo

guardian_jwe's Introduction

Guardian.Token.Jwe Hex.pm

This package is a plugin for Guardian.

Documentation

API documentation is available at https://hexdocs.pm/guardian_jwe

Installation

To install Guardian.Token.Jwe, first add it to your mix.exs file:

def deps do
  [
    {:guardian_jwe, "~> 0.2.0"}
  ]
end

To use JWEs, you'll need to configure the token_module parameter in your Guardian implementation module.

defmodule GuardianTest.Auth do
  use Guardian,
    otp_app: :guardian_test,
    token_module: Guardian.Token.Jwe

  def subject_for_token(resource, _claims) do
    sub = to_string(resource.id)

    {:ok, sub}
  end

  def resource_from_claims(claims) do
    {:ok, claims}
  end
end

To change the default algorithm used to encrypt JWEs, set the allowed_algos in your Guardian configuration:

config :guardian_test, GuardianTest.Auth,
       issuer: "guardian_test",
       allowed_algos: ["A128GCMKW"],
       secret_key: "aaaaaaaaaaaaaaaa"

The JWE module uses the same claims and validations as JWT for verification. With this configuration, your application should work without additional changes to your Guardian configuration.

Implemented algorithms

Currently, this package supports the following algorithms for encrypting JWT tokens.

A128GCMKW
A192GCMKW
A256GCMKW

PBES2-HS256+A128KW
PBES2-HS384+A192KW
PBES2-HS512+A256KW

Each of the AxxxGCMKW require keys of specific bit sizes where the xxx corresponds to the required size of the key.

The PBES2-HSxxx+AxxxKW secret can be generated using mix guardian.gen.secret.

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/guardian_jwe.

guardian_jwe's People

Contributors

davepersing avatar doomspork avatar mosic avatar yordis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.