lvivski / start

Sinatra inspired web development framework for Dart

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Experimental JWT plugin for Start web framework.

bsjung opened this issue · comments

Start JWT
- originally developed by George Moschovitis george.moschovitis@gmail.com.
- Dart2 converted by JarrodCColburn at https://github.com/JarrodCColburn.
- tested by Benjamin Jung at https://github.com/bsjung/start_jwt.

Benjamin Jung (bsjung@gmail.com)

I've added JWT in https://github.com/bsjung/start_examples.

It's very simple and works.

import 'package:start_jwt/json_web_token.dart';

void main() {

// Encode (i.e. sign) a payload into a JWT token.

final jwt = new JsonWebTokenCodec(secret: "My secret key");
final payload = {
  'iss': 'joe',
  'exp': 1300819380,
  'http://example.com/is_root': true
};
final token = jwt.encode(payload);
print ("Payload : " + payload.toString());

// Validate a token.

jwt.isValid(token);

// Decode (i.e. extract) the payload from a JWT token.

final decoded = jwt.decode(token);
print ("Decoded : " + decoded.toString());

}


start_jwt package is uploaded into https://pub.dev/packages/start_jwt.

JWT is definitely helpful in many scenarios. Thanks for publishing the package.