A JSON Web Token implementation in Objective-C.
Add the following to your Cocoapods Podfile:
pod 'JWT', git: 'https://github.com/yourkarma/JWT.git', tag: '1.0.0'
You can encode arbitrary payloads like so:
[JWT encodePayload:@{@"foo": @"bar"} withSecret:@"secret"];
If you're using reserved claim names you can encode your claim set like so (all properties are optional):
JWTClaimsSet *claimsSet = [[JWTClaimsSet alloc] init];
claimsSet.issuer = @"Facebook";
claimsSet.subject = @"Token";
claimsSet.audience = @"http://yourkarma.com";
claimsSet.expirationDate = [NSDate distantFuture];
claimsSet.notBeforeDate = [NSDate distantPast];
claimsSet.issuedAt = [NSDate date];
claimsSet.identifier = @"thisisunique";
claimsSet.type = @"test";
[JWT encodeClaimsSet:claimsSet withSecret:@"secret"];
The library currently only supports HS512 - HMAC using SHA-512. Additional algorithms can be added by implementing the KWTAlgorithm
protocol.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request