Skip to content

Instantly share code, notes, and snippets.

@matzew
Created October 4, 2012 12:46
Show Gist options
  • Save matzew/3833333 to your computer and use it in GitHub Desktop.
Save matzew/3833333 to your computer and use it in GitHub Desktop.
AGAuthenticationModule
/**
* AGAuthenticationModule represents an authentication module...
*/
@protocol AGAuthenticationModule <NSObject>
/**
* Returns the type of the underlying 'auth module implementation'
*/
@property (nonatomic, readonly) NSString* type;
/**
* Returns the baseURL string of the underlying 'auth module implementation'
*/
@property (nonatomic, readonly) NSString* baseURL;
/**
* Returns the 'login endpoint' of the underlying 'auth module implementation'
*/
@property (nonatomic, readonly) NSString* loginEndpoint;
/**
* Returns the 'logout endpoint' of the underlying 'auth module implementation'
*/
@property (nonatomic, readonly) NSString* logoutEndpoint;
/**
* Returns the 'enroll endpoint' of the underlying 'auth module implementation'
*/
@property (nonatomic, readonly) NSString* enrollEndpoint;
/**
* Performs a register of a new user. The request accepts a NSDictionary which will be translated to JSON
* and send to the endpoint. Since 'register' is a c keyword, this method is named 'enroll:success:failure'.
*
* @param userData A map (NSDictionary) containing all the information requested by the
* 'registration' service.
*
* @param success A block object to be executed when the operation finishes successfully.
* This block has no return value and takes one argument: A collection (NSDictionary), containing the response
* from the 'signup' service.
*
* @param failure A block object to be executed when the operation finishes unsuccessfully.
* This block has no return value and takes one argument: The `NSError` object describing
* the error that occurred.
*/
-(id) enroll:(id) userData
success:(void (^)(id object))success
failure:(void (^)(NSError *error))failure;
/**
* Performs the login of the give user. Since the data will be send in plaintext, it is IMPORTANT,
* to run the signin via TLS/HTTPS.
*
* @param username username
*
* @param password password
*
* @param success A block object to be executed when the operation finishes successfully.
* This block has no return value and takes one argument: A collection (NSDictionary), containing the response
* from the 'login' service.
*
* @param failure A block object to be executed when the operation finishes unsuccessfully.
* This block has no return value and takes one argument: The `NSError` object describing
* the error that occurred.
*/
-(id) login:(NSString*) username
password:(NSString*) password
success:(void (^)(id object))success
failure:(void (^)(NSError *error))failure;
/**
* Performs the logout of the current user.
*
* @param success A block object to be executed when the operation finishes successfully.
* This block has no return value and takes no argument.
*
* @param failure A block object to be executed when the operation finishes unsuccessfully.
* This block has no return value and takes one argument: The `NSError` object describing
* the error that occurred.
*/
-(id) logout:(void (^)())success
failure:(void (^)(NSError *error))failure;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment