squarealfa_security 3.4.0 copy "squarealfa_security: ^3.4.0" to clipboard
squarealfa_security: ^3.4.0 copied to clipboard

Package containing security-related features, like JWT token handling and password hashing.

SquareAlfa Security Package #

JWT #

The following example shows how to generate a JWT token.

    
    var secret = '62zb8Sky_i_2kNAKFkORRa42XlQK09Bdtl_GHkTN';

    // the JsonWebTokenHandler handles the generation and parsing of JWT tokens.
    var tokenGenerator = JsonWebTokenHandler(secret);

    // create the payload
    var claims = JwtPayload(
        name: 'John Doe',
        email: 'user@domain.com',
        subject: '5f35bd0489d72e2cd430f78d',
        issuer: 'Our Server',
        audience: 'Our Server',
        notBefore: DateTime.now(),
        expires: DateTime.now().add(Duration(seconds: 300)));

    // finally, generate the JWT token.
    var jwt = tokenGenerator.generate(claims);


The following code parses a JWT token:


      var tokenGenerator = JsonWebTokenHandler(secret);
      var jwt =
          'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSm9obiBEb2UiLCJzdWIiOiI1ZjM1YmQwNDg5ZDcyZTJjZDQzMGY3OGQiLCJlbWFpbCI6InVzZXJAZG9tYWluLmNvbSIsImlzcyI6Ik91ciBTZXJ2ZXIiLCJhdWQiOiJPdXIgU2VydmVyIiwibmJmIjoiMTYwNTMyNjEyOCIsImV4cCI6IjE2MDUzMjY0MjgiLCJyb2xlcyI6bnVsbCwidWlkIjpudWxsLCJ0aWQiOm51bGx9.d9+mbsXtv5Xv2yAwaD1X4zOLM5aYa3edmQcYSSCP+II';
      var payload = tokenGenerator.load(jwt);

Context #

This package is part of a set of losely integrated packages that constitute the Dartaculous Framework.

2
likes
140
pub points
35%
popularity

Publisher

verified publishersquarealfa.com

Package containing security-related features, like JWT token handling and password hashing.

Homepage
Repository (GitLab)
View/report issues
Contributing

Documentation

API reference

License

MPL-2.0 (LICENSE)

Dependencies

crypto, cryptography, http, jose

More

Packages that depend on squarealfa_security