Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token Auth and cryptography fixes and renaming #9

Merged
merged 1 commit into from
Apr 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

An iOS client library for [ably.io](https://www.ably.io), the realtime messaging service, written in Objective-C.

## Installation
## CocoaPod Installation
add pod ably to your Podfile. While ably-ios is in development, use this line instead:
* pod "ably", :git => 'https://github.com/thevixac/ably-ios.git', :commit => 'be670f5e6c3'

## Manual Installation

* git clone https://github.com/ably/ably-ios
* drag the directory ably-ios/ably-ios into your project as a group
* git clone https://github.com/square/SocketRocket.git
* drag the directory SocketRocket/SocketRocket into your project as a group



## Using the Realtime API

### Connection
Expand Down Expand Up @@ -106,14 +108,10 @@ The library works on iOS8, and uses [SocketRocket](https://github.com/square/Soc
The following features are not implemented yet:

* msgpack transportation
* 256 cryptography

The following features are do not have sufficient test coverage:

* 128 cryptography
* app stats
* capability
* token auth

## Support and feedback

Expand Down
36 changes: 22 additions & 14 deletions ably-ios/ARTAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,44 @@

@class ARTRest;

@interface ARTAuthToken : NSObject
@interface ARTTokenDetails : NSObject

@property (readonly, strong, nonatomic) NSString *id;
@property (readonly, strong, nonatomic) NSString *token;
@property (readonly, assign, nonatomic) int64_t expires;
@property (readonly, assign, nonatomic) int64_t issuedAt;
@property (readonly, assign, nonatomic) int64_t issued;
@property (readonly, strong, nonatomic) NSString *capability;
@property (readonly, strong, nonatomic) NSString *clientId;

- (instancetype)init UNAVAILABLE_ATTRIBUTE;

- (instancetype)initWithId:(NSString *)id expires:(int64_t)expires issuedAt:(int64_t)issuedAt capability:(NSString *)capability clientId:(NSString *)clientId;
- (instancetype)initWithId:(NSString *)id expires:(int64_t)expires issued:(int64_t)issued capability:(NSString *)capability clientId:(NSString *)clientId;

+ (instancetype)authTokenWithId:(NSString *)id expires:(int64_t)expires issuedAt:(int64_t)issuedAt capability:(NSString *)capability clientId:(NSString *)clientId;
+ (instancetype)authTokenWithId:(NSString *)id expires:(int64_t)expires issued:(int64_t)issued capability:(NSString *)capability clientId:(NSString *)clientId;

@end

@interface ARTAuthTokenParams : NSObject

@property (readonly, strong, nonatomic) NSString *id;
@property (readonly, strong, nonatomic) NSString *keyName;
@property (readonly, assign, nonatomic) int64_t ttl;
@property (readonly, strong, nonatomic) NSString *capability;
@property (readonly, strong, nonatomic) NSString *clientId;
@property (readonly, assign, nonatomic) int64_t timestamp;
@property (readonly, strong, nonatomic) NSString *nonce;
@property (readonly, strong, nonatomic) NSString *mac;


- (instancetype)init UNAVAILABLE_ATTRIBUTE;

- (instancetype)initWithId:(NSString *)id ttl:(int64_t)ttl capability:(NSString *)capability clientId:(NSString *)clientId timestamp:(int64_t)timestamp nonce:(NSString *)nonce mac:(NSString *)mac;

+ (instancetype)authTokenParamsWithId:(NSString *)id ttl:(int64_t)ttl capability:(NSString *)capability clientId:(NSString *)clientId timestamp:(int64_t)timestamp nonce:(NSString *)nonce mac:(NSString *)mac;

-(NSDictionary *) asDictionary;
@end

typedef id<ARTCancellable>(^ARTAuthCb)(void(^continuation)(ARTAuthToken *));
typedef id<ARTCancellable>(^ARTSignedTokenRequestCb)(ARTAuthTokenParams *tokenParams, void(^continuation)(NSString *));
typedef id<ARTCancellable>(^ARTAuthCb)(void(^continuation)(ARTStatus,ARTTokenDetails *));
typedef id<ARTCancellable>(^ARTSignedTokenRequestCb)(ARTAuthTokenParams *, void(^continuation)(ARTAuthTokenParams *));
typedef NS_ENUM(NSUInteger, ARTAuthMethod) {
ARTAuthMethodBasic,
ARTAuthMethodToken
Expand All @@ -59,12 +61,15 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) {
@property (readwrite, strong, nonatomic) ARTAuthCb authCallback;
@property (readwrite, strong, nonatomic) ARTSignedTokenRequestCb signedTokenRequestCallback;
@property (readwrite, strong, nonatomic) NSURL *authUrl;
@property (readwrite, strong, nonatomic) NSString *keyId;
@property (readwrite, strong, nonatomic) NSString *keyValue;
@property (readwrite, strong, nonatomic) NSString *authToken;
@property (readwrite, strong, nonatomic) NSString *keyName;
@property (readwrite, strong, nonatomic) NSString *keySecret;
@property (readwrite, strong, nonatomic) NSString *token;
@property (readwrite, strong, nonatomic) NSString *capability;
@property (readwrite, strong, nonatomic) NSDictionary *authHeaders;
@property (readwrite, strong, nonatomic) NSString *clientId;
@property (readwrite, assign, nonatomic) BOOL queryTime;
@property (readwrite, assign, nonatomic) BOOL useTokenAuth;


- (instancetype)init;
- (instancetype)initWithKey:(NSString *)key;
Expand All @@ -80,9 +85,12 @@ typedef NS_ENUM(NSUInteger, ARTAuthMethod) {

- (instancetype)initWithRest:(ARTRest *)rest options:(ARTAuthOptions *)options;

- (id<ARTCancellable>)authHeaders:(id<ARTCancellable>(^)(NSDictionary *))cb;

- (ARTAuthMethod) getAuthMethod;
- (id<ARTCancellable>)authHeadersUseBasic:(BOOL)useBasic cb:(id<ARTCancellable>(^)(NSDictionary *))cb;
- (id<ARTCancellable>)authParams:(id<ARTCancellable>(^)(NSDictionary *))cb;
- (id<ARTCancellable>)authToken:(id<ARTCancellable>(^)(ARTAuthToken *))cb;
- (id<ARTCancellable>)authTokenForceReauth:(BOOL)force cb:(id<ARTCancellable>(^)(ARTAuthToken *))cb;
- (id<ARTCancellable>)authToken:(id<ARTCancellable>(^)(ARTTokenDetails *))cb;
- (id<ARTCancellable>)authTokenForceReauth:(BOOL)force cb:(id<ARTCancellable>(^)(ARTTokenDetails *))cb;


@end
Loading