A JSON Web Token implementation in Objective-C.
Add the following to your Cocoapods Podfile:
pod "JWT"
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 following algorithms are supported:
- HS512 - HMAC using SHA-512.
- HS256
- None
Additional algorithms can be added by implementing the JWTAlgorithm
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