jaguar_jwt 0.2.0 copy "jaguar_jwt: ^0.2.0" to clipboard
jaguar_jwt: ^0.2.0 copied to clipboard

outdatedDart 1 only

JWT utilities for Jaguar.dart

Build Status

jaguar_jwt #

JWT utilities for Jaguar.dart

Configuration #

AuthenticationConf #

AuthenticationConf object holds configuration to issue JWT token during authentication phase. To issue a JWT token, it needs:

  1. issuer
    Authority issuing the token. This will be used during authorization to verify that expected issuer has issued the token. Fills the iss field of the JWT token
  2. audience
    List of audience that accept this token. This will be used during authorization to verify that JWT token has expected audience for the service. Fills aud field in JWT token
  3. tokenDuration
    Duration for which the issued JWT token is valid. Fills exp field in JWT token
  4. signatureContext
    The signature context to sign the JWT token with

AuthorizationConf #

AuthorizationConf object holds configuration to decode and validate JWT token during authorization phase.

  1. issuer
    The allowed/expected issuer. The issuer of the incoming JWT token must match this field for authorization to succeed
  2. audience Allowed audience. Incoming JWT token must contain at least one of these audiences for the authorization to succeed.
  3. signatureContext
    The signature context to verify the signature of JWT token.

Usage #

Encoding/issuing JWT token #

final encoder = new AuthenticationConf.SymmetricKey(
  'dfsdffasdfdgdfgdfg456456456', 'teja',
  audience: <String>['admin', 'students']);

ClaimSet claimSet =
  new ClaimSet('kleak', encoder.issuer, encoder.audience, {'k': 'v'});
String encoded = encoder.encodeClaimSet(claimSet);
print(encoded);

Decoding JWT token #

final decoder = new AuthorizationConf.SymmetricKey(
  'dfsdffasdfdgdfgdfg456456456', 'teja',
  audience: <String>['students']);
JsonWebToken decoded = decoder.decodeToken(encoded);
print(decoded.claimSet.toJson());
76
likes
0
pub points
96%
popularity

Publisher

unverified uploader

JWT utilities for Jaguar.dart

Homepage

License

unknown (LICENSE)

Dependencies

auth_header, dart_jwt

More

Packages that depend on jaguar_jwt