Initial stab at documentation.
This commit is contained in:
parent
a87f92da2d
commit
d566d31ac3
@ -1,3 +1,17 @@
|
|||||||
|
# jwt.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
##
|
||||||
|
## ===============================
|
||||||
|
## jwt
|
||||||
|
## ===============================
|
||||||
|
##
|
||||||
|
## -------------------------------
|
||||||
|
## JSON Web Token (JWT) - RFC 7519
|
||||||
|
## -------------------------------
|
||||||
|
##
|
||||||
|
##
|
||||||
|
|
||||||
import jwt/jwa, jwt/jwe, jwt/jwk, jwt/jws, jwt/jwt
|
import jwt/jwa, jwt/jwe, jwt/jwk, jwt/jws, jwt/jwt
|
||||||
|
|
||||||
export jwa, jwe, jwk, jws, jwt
|
export jwa, jwe, jwk, jws, jwt
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
# jwt/claims.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ====================================
|
||||||
|
## claims
|
||||||
|
## ====================================
|
||||||
|
##
|
||||||
|
## ------------------------------------
|
||||||
|
## JWT Claims Object
|
||||||
|
## ------------------------------------
|
||||||
|
##
|
||||||
|
## Data structures and utility procedures for working with JWT claims objects.
|
||||||
|
## This module follows the common pattern in this library of providing direct
|
||||||
|
## access to all of the claims members via the `[]` syntax, as well as
|
||||||
|
## convencience accessors for the publicly-defined claims.
|
||||||
|
|
||||||
import std/json, std/options, std/times
|
import std/json, std/options, std/times
|
||||||
|
|
||||||
import ../private/encoding
|
import ../private/encoding
|
||||||
@ -16,8 +32,8 @@ type
|
|||||||
iat: Option[DateTime]
|
iat: Option[DateTime]
|
||||||
jti: Option[string]
|
jti: Option[string]
|
||||||
|
|
||||||
## Public read-only accessors to JwtClaims members
|
# Public read-only accessors to JwtClaims members
|
||||||
## -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|
||||||
func rawB64*(c: JwtClaims): string = c.rawB64
|
func rawB64*(c: JwtClaims): string = c.rawB64
|
||||||
func iss*(c: JwtClaims): Option[string] = c.iss
|
func iss*(c: JwtClaims): Option[string] = c.iss
|
||||||
@ -33,7 +49,10 @@ func `[]`*(c: JwtClaims, key: string): Option[JsonNode] =
|
|||||||
if c.json.hasKey(key): some(c.json[key])
|
if c.json.hasKey(key): some(c.json[key])
|
||||||
else: none[JsonNode]()
|
else: none[JsonNode]()
|
||||||
|
|
||||||
proc `$`*(claims: JwtClaims): string = claims.rawB64
|
proc `$`*(claims: JwtClaims): string =
|
||||||
|
## Serialize a JwtClaims object to a Base64url-encoded string (as per the JWT
|
||||||
|
## standard).
|
||||||
|
claims.rawB64
|
||||||
|
|
||||||
proc initJwtClaims*(n: JsonNode): JwtClaims =
|
proc initJwtClaims*(n: JsonNode): JwtClaims =
|
||||||
## Create a JwtClaims from a given set of claims as a JsonNOde
|
## Create a JwtClaims from a given set of claims as a JsonNOde
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
# jwt/joseheader.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ====================================
|
||||||
|
## joseheader
|
||||||
|
## ====================================
|
||||||
|
##
|
||||||
|
## ------------------------------------
|
||||||
|
## JOSE Header
|
||||||
|
## ------------------------------------
|
||||||
|
##
|
||||||
|
## Data structures and utility procedures for working with JOSE headers. This
|
||||||
|
## module follows the common pattern in this library of providing direct access
|
||||||
|
## to all of the header parameters via the `[]` syntax, as well as convencience
|
||||||
|
## accessors for the publicly-defined header parameters.
|
||||||
|
|
||||||
import std/json, std/options, std/sequtils, std/strutils
|
import std/json, std/options, std/sequtils, std/strutils
|
||||||
|
|
||||||
import ./jwa, ./jwk
|
import ./jwa, ./jwk
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
# jwt/jwa.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
##
|
||||||
|
## ====================================
|
||||||
|
## jwa
|
||||||
|
## ====================================
|
||||||
|
##
|
||||||
|
## ------------------------------------
|
||||||
|
## JSON Web Algorithms (JWA) - RFC 7518
|
||||||
|
## ------------------------------------
|
||||||
|
##
|
||||||
|
## Enum values reflecting the names of algorithms defined by JWA RFC 7518.
|
||||||
|
|
||||||
type
|
type
|
||||||
JwtKeyType* = enum ktyEC = "EC", ktyRSA = "RSA", ktyOctet = "oct"
|
JwtKeyType* = enum ktyEC = "EC", ktyRSA = "RSA", ktyOctet = "oct"
|
||||||
|
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
# jwt/jwe.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ====================================
|
||||||
|
## jwe
|
||||||
|
## ====================================
|
||||||
|
##
|
||||||
|
## ------------------------------------
|
||||||
|
## JSON Web Encryption (JWE) - RFC 7516
|
||||||
|
## ------------------------------------
|
||||||
|
##
|
||||||
|
|
||||||
import ./joseheader
|
import ./joseheader
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
# jwt/jwk.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ==============================
|
||||||
|
## jwk
|
||||||
|
## ==============================
|
||||||
|
##
|
||||||
|
## ------------------------------
|
||||||
|
## JSON Web Keys (JWK) - RFC 7518
|
||||||
|
## ------------------------------
|
||||||
|
##
|
||||||
|
## Nim implementation of the data structures and constants defined in RFC 7518.
|
||||||
|
|
||||||
import std/json, std/options, std/sequtils, std/strutils
|
import std/json, std/options, std/sequtils, std/strutils
|
||||||
|
|
||||||
import ../private/jsonutils
|
import ../private/jsonutils
|
||||||
@ -63,8 +76,8 @@ type
|
|||||||
|
|
||||||
JwkSet* = seq[JWK]
|
JwkSet* = seq[JWK]
|
||||||
|
|
||||||
## Read-only public accessors to JWK members
|
# Read-only public accessors to JWK members
|
||||||
## -----------------------------------------
|
# -----------------------------------------
|
||||||
|
|
||||||
func kty*(jwk: JWK): string = jwk.kty
|
func kty*(jwk: JWK): string = jwk.kty
|
||||||
func use*(jwk: JWK): Option[string] = jwk.use
|
func use*(jwk: JWK): Option[string] = jwk.use
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
# jwt/jws.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ====================================
|
||||||
|
## jws
|
||||||
|
## ====================================
|
||||||
|
##
|
||||||
|
## ------------------------------------
|
||||||
|
## JSON Web Signature (JWS) - RFC 7515
|
||||||
|
## ------------------------------------
|
||||||
|
##
|
||||||
|
|
||||||
import std/json, std/logging, std/options, std/sequtils, std/strutils
|
import std/json, std/logging, std/options, std/sequtils, std/strutils
|
||||||
|
|
||||||
import ../private/crypto
|
import ../private/crypto
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
# jwt/jwssig.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## =====================================
|
||||||
|
## JwsSig
|
||||||
|
## =====================================
|
||||||
|
##
|
||||||
|
## -------------------------------------
|
||||||
|
## JwsSignature object and procedures.
|
||||||
|
## -------------------------------------
|
||||||
|
|
||||||
import std/json, std/options
|
import std/json, std/options
|
||||||
|
|
||||||
import ./jwa
|
import ./jwa
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
# jwt/jwt.nim
|
||||||
|
# Copyright 2021 Jonathan Bernard
|
||||||
|
|
||||||
|
## ===============================
|
||||||
|
## jwt
|
||||||
|
## ===============================
|
||||||
|
##
|
||||||
|
## -------------------------------
|
||||||
|
## JSON Web Token (JWT) - RFC 7519
|
||||||
|
## -------------------------------
|
||||||
|
##
|
||||||
|
##
|
||||||
|
|
||||||
import std/json, std/options, std/strutils, std/times
|
import std/json, std/options, std/strutils, std/times
|
||||||
|
|
||||||
import ./claims, ./joseheader, ./jwa, ./jwe, ./jwk, ./jws, ./jwssig
|
import ./claims, ./joseheader, ./jwa, ./jwe, ./jwk, ./jws, ./jwssig
|
||||||
@ -15,8 +28,8 @@ type
|
|||||||
of jkJWE: jwe: JWE
|
of jkJWE: jwe: JWE
|
||||||
of jkJWS: jws: JWS
|
of jkJWS: jws: JWS
|
||||||
|
|
||||||
## Public read-only accessors to JWT members
|
# Public read-only accessors to JWT members
|
||||||
## -----------------------------------------
|
# -----------------------------------------
|
||||||
|
|
||||||
func claims*(jwt: JWT): JwtClaims = jwt.claims
|
func claims*(jwt: JWT): JwtClaims = jwt.claims
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user