All Projects → timonson → Djwt

timonson / Djwt

Licence: mit
Create and verify JSON Web Tokens (JWT) with deno.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Djwt

Django Graphql Jwt
JSON Web Token (JWT) authentication for Graphene Django
Stars: ✭ 649 (+597.85%)
Mutual labels:  authentication, jwt, jsonwebtoken
Hapi Auth Keycloak
JSON Web Token based Authentication powered by Keycloak
Stars: ✭ 29 (-68.82%)
Mutual labels:  authentication, jwt, jsonwebtoken
Spring Boot Jwt
JWT auth service using Spring Boot, Spring Security and MySQL
Stars: ✭ 795 (+754.84%)
Mutual labels:  authentication, jwt, jsonwebtoken
Sjwt
Simple JWT Golang
Stars: ✭ 86 (-7.53%)
Mutual labels:  authentication, jwt, jsonwebtoken
Authentication Server
A simple authentication service to deliver JWT with Hasura claims, based on users with multiples roles stored in a Postgres database.
Stars: ✭ 48 (-48.39%)
Mutual labels:  authentication, jwt
Django Graphql Social Auth
Python Social Auth support for Graphene Django
Stars: ✭ 90 (-3.23%)
Mutual labels:  authentication, jwt
Ngx Api Utils
ngx-api-utils is a lean library of utilities and helpers to quickly integrate any HTTP API (REST, Ajax, and any other) with Angular.
Stars: ✭ 92 (-1.08%)
Mutual labels:  authentication, jwt
Flask Restful Authentication
An example for RESTful authentication using nginx, uWSGI, Flask, MongoDB and JSON Web Token(JWT).
Stars: ✭ 63 (-32.26%)
Mutual labels:  authentication, jwt
Google Auth Library Nodejs
🔑 Google Auth Library for Node.js
Stars: ✭ 1,094 (+1076.34%)
Mutual labels:  authentication, jwt
Grpc Auth Example
Examples of client authentication with gRPC
Stars: ✭ 65 (-30.11%)
Mutual labels:  authentication, jwt
Vouch Proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module
Stars: ✭ 1,239 (+1232.26%)
Mutual labels:  authentication, jwt
Jose
Universal "JSON Web Almost Everything" - JWA, JWS, JWE, JWT, JWK with no dependencies
Stars: ✭ 1,029 (+1006.45%)
Mutual labels:  jwt, jsonwebtoken
Paseto
Java Implementation of Platform-Agnostic Security Tokens - https://paseto.io
Stars: ✭ 32 (-65.59%)
Mutual labels:  authentication, jwt
Dashboard Server
A JSON file RESTful API with authorization based on json-server
Stars: ✭ 48 (-48.39%)
Mutual labels:  jwt, jsonwebtoken
Bottle Jwt
JWT Authentication Plugin for bottle.py applications.
Stars: ✭ 30 (-67.74%)
Mutual labels:  authentication, jwt
Ldap Jwt
Lightweight node.js based web service that provides user authentication against LDAP server (Active Directory / Windows network) credentials and returns a JSON Web Token.
Stars: ✭ 58 (-37.63%)
Mutual labels:  authentication, jwt
Authex
Authex is an opinionated JWT authentication and authorization library for Elixir.
Stars: ✭ 73 (-21.51%)
Mutual labels:  authentication, jwt
Go Alone
A simple to use, high-performance, Go (golang) MAC signer.
Stars: ✭ 82 (-11.83%)
Mutual labels:  authentication, jwt
Access
Ponzu Addon to manage API access grants and tokens for authentication
Stars: ✭ 13 (-86.02%)
Mutual labels:  authentication, jwt
Devise Jwt
JWT token authentication with devise and rails
Stars: ✭ 881 (+847.31%)
Mutual labels:  authentication, jwt

djwt

Create and verify JSON Web Tokens with deno.

API

create

Takes a header, payload and key and returns the url-safe encoded jwt.

import { create } from "https://deno.land/x/[email protected]$VERSION/mod.ts"

const jwt = await create({ alg: "HS512", typ: "JWT" }, { foo: "bar" }, "secret")
// eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.WePl7achkd0oGNB8XRF_LJwxlyiPZqpdNgdKpDboAjSTsWq-aOGNynTp8TOv8KjonFym8vwFwppXOLoLXbkIaQ

verify

Takes a jwt, key and an algorithm and returns the payload of the jwt if the jwt is valid. Otherwise it throws an Error.

import { verify } from "https://deno.land/x/[email protected]$VERSION/mod.ts"

const payload = await verify(jwt, "secret", "HS512") // { foo: "bar" }

decode

Takes a jwt and returns a 3-tuple [header, payload, signature] if the jwt has a valid serialization. Otherwise it throws an Error.

import { decode } from "https://deno.land/x/[email protected]$VERSION/mod.ts"

const jwt =
  "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.WePl7achkd0oGNB8XRF_LJwxlyiPZqpdNgdKpDboAjSTsWq-aOGNynTp8TOv8KjonFym8vwFwppXOLoLXbkIaQ"

const [header, payload, signature] = decode(jwt)
// [
// { alg: "HS512", typ: "JWT" },
// { foo: "bar" },
// "59e3e5eda72191dd2818d07c5d117f2c9c3197288f66aa5d36074aa436e8023493b16abe68e18dca74e9f133aff0a8e89c5c..."
// ]

getNumericDate

This helper function simplifies setting a NumericDate. It takes either a Date object or a number (in seconds) and returns the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time.

// A specific date:
getNumericDate(new Date("2025-07-01"))
// One hour from now:
getNumericDate(60 * 60)

Claims

Expiration Time (exp)

The optional exp claim in the payload identifies the expiration time on or after which the JWT must not be accepted for processing. Its value must be a number containing a NumericDate value. This module checks if the current date/time is before the expiration date/time listed in the exp claim.

const jwt = await create(header, { exp: getNumericDate(60 * 60) }, "secret")

Not Before (nbf)

The optional nbf (not before) claim identifies the time before which the jwt must not be accepted for processing. Its value must be a number containing a NumericDate value.

Algorithms

The following signature and MAC algorithms have been implemented:

  • HS256 (HMAC SHA-256)
  • HS512 (HMAC SHA-512)
  • RS256 (RSASSA-PKCS1-v1_5 SHA-256)
  • RS512 (RSASSA-PKCS1-v1_5 SHA-512)
  • PS256 (RSASSA-PSS SHA-256)
  • PS512 (RSASSA-PSS SHA-512)
  • none (Unsecured JWTs).

Serialization

This application uses the JWS Compact Serialization only.

Specifications

Contribution

Every kind of contribution to this project is highly appreciated. Please run deno fmt on the changed files before making a pull request.

Big Thank you to timreichen and all the other amazing contributors.

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