redo BITAuthenticator interface

given the good feedback we got, this is take 2
of the BITAuthenticator interface.
It's simplified, cleaned up and now allows full
control over the authentication process.
Major changes:
* manual mode
  Authenticator provides the bits to show the
  viewController to identify the user as well as to
  trigger validation on behalf of the developer.
* process separation
  identification and app-usage-restriction are now
  2 completely separated things.
* public identifier
  Authenticator now allows the developer to query
  parts of the information, e.g. the UDID or the user's
  emailaddy once identified
This commit is contained in:
Stephan Diederich
2013-09-23 23:15:56 +02:00
parent 5ac00ff174
commit c2c6558687
10 changed files with 618 additions and 833 deletions

View File

@@ -42,71 +42,22 @@
*/
@property (nonatomic, strong) BITHockeyAppClient *hockeyAppClient;
#pragma mark - Identification
/**
* Provides an identification for the current app installation
*
* During Alpha and Beta-phase HockeyApp tries to uniquely identify each app installation
* to provide better error reporting & analytics. If authenticator is configured to login
* (@see BITAuthenticatorValidationType), this identifier is retrieved from HockeyApp. In case
* it is disabled, it returns the vendorIdentifier provided by UIKit.
* KVO'able
*
* @return a string identifying this app installation
*/
@property (nonatomic, readonly) NSString *installationIdentification;
/**
* Specifies if the installationIdentification has been validated
*
* Depending on authenticationType and validationType this flag switches between
* YES/NO during application runtime. If it's YES, the installationIdentification has been
* validated (either against the backend on app launch / initial run of this version) or validation
* is not required. The flag is first updated (and stays NO) until the manager has been started.
* KVO'able
*/
@property (nonatomic, readwrite) BOOL installationIdentificationValidated;
/**
* Specifies the type of installation identification for the current app installation
*/
@property (nonatomic, readonly) NSString *installationIdentificationType;
#pragma mark -
//can be set for testing
@property (nonatomic) UIDevice *currentDevice;
#pragma mark -
/**
* if set, this serves as the installationIdentifier.
* This is retrieved from the hockeyApp backend
* @see installationIdentification
*/
@property (nonatomic, readonly) NSString *authenticationToken;
/**
* store the authentication token with the given type
* if authToken is not nil, authentikationTokenType must also be non nil
*
* @param authenticationToken The authentication token
* @param authenticationTokenType The authentication token type
*/
- (void)setAuthenticationToken:(NSString *)authenticationToken withType:(NSString*) authenticationTokenType;
/**
* holds the identifier of the last version that was authenticated
* only used if validation is set BITAuthenticatorValidationTypeOnFirstLaunch
*/
@property (nonatomic, copy) NSString *lastAuthenticatedVersion;
@property (nonatomic, copy) tAuthenticationCompletion authenticationCompletionBlock;
/**
* return the string used to identify this app against the HockeyApp backend.
*/
@property (nonatomic, copy, readonly) NSString *installationIdentifierTypeString;
/**
* removes all previously stored authentication tokens, UDIDs, etc
* returns the string used to identify this app against the HockeyApp backend.
*/
- (void) cleanupInternalStorage;
@property (nonatomic, copy, readonly) NSString *installationIdentifier;
/**
* method registered as observer for applicationWillBecomeInactive events
@@ -122,49 +73,14 @@
*/
- (void) applicationDidBecomeActive:(NSNotification*) note;
/**
* once the user skipped the optional login, this is set to YES
* (and thus the optional login should never be shown again)
* persisted to disk. Defaults to NO
*/
@property (nonatomic, assign) BOOL didSkipOptionalLogin;
@property (nonatomic, copy) void(^identificationCompletion)(BOOL identified, NSError* error);
#pragma mark - Authentication
/**
* Authenticate this app installation
*
* Depending on 'authenticationType', this tries to authenticate the app installation
* against the HockeyApp server.
* You should not need to call this, as it's done automatically once the manager has
* been started, depending on validationType.
*
* @param completion if nil, success/failure is reported via the delegate, if not nil, the
* delegate methods are not called.
*/
- (void) authenticateWithCompletion:(tAuthenticationCompletion) completion;
#pragma mark - Overrides
@property (nonatomic, assign, readwrite, getter = isIdentified) BOOL identified;
@property (nonatomic, assign, readwrite, getter = isValidated) BOOL validated;
#pragma mark - Internal Auth callbacks
- (void) didAuthenticateWithToken:(NSString*) token;
#pragma mark - Validation
/**
* Validate the app installation
*
* Depending on @see validationType, this is called by the manager after the app becomes active
* and tries to revalidate the installation.
* You should not need to call this, as it's done automatically once the manager has
* been started, depending on validationType.
*
* @param completion if nil, success/failure is reported via the delegate, if not nil, the
* delegate methods are not called
*/
- (void) validateInstallationWithCompletion:(tValidationCompletion) completion;
#pragma mark - Validation callbacks
- (void) validationSucceededWithCompletion:(tValidationCompletion) completion;
- (void) validationFailedWithError:(NSError *) validationError completion:(tValidationCompletion) completion;
#pragma mark - Helpers for testing
- (tValidationCompletion) defaultValidationCompletionBlock;
#pragma mark - Testing
- (void) storeInstallationIdentifier:(NSString*) identifier withType:(BITAuthenticatorIdentificationType) type;
- (BOOL) needsValidation;
- (void) authenticate;
@end