Custom iOS user authentication mechanism (password with security questions for self reset)
The “iMAS App Password” framework provides a simple way to include passcode support into your application. It has the logic to enforce passcode strength, and can react to any passcode input. The framework contains two types of passcode controls, a simple passcode (numeric) and a complex passcode (a combination of numbers and characters). The framework utilizes the “iMAS Secure Foundation” framework in order to provide advanced security for both types of controls.
Add the App Password repository as a submodule to your project. git submodule add [email protected]:project-imas/app-password.git vendor/app-password
Add the Secure Foundation repository as a submodule to your project. git submodule add [email protected]:project-imas/securefoundation.git vendor/securefoundation
Drag AppPassword.xcodeproj into the your project as a subproject
Drag SecureFoundation.xcodeproj into the your project as a subproject
Add AppPassword to target’s build phase - target dependencies
Add libSecureFoundation.a to target’s build phase - target dependencies
Drag AppPassword.framework to target’s build phase - link binary with libraries
Add libSecureFoundation.a to target’s build phase - link binary with libraries
Add Security.framework to target’s build phase - link binary with libraries
Add QuartzCore.framework to target’s build phase - link binary with libraries
Add AppPassword.framework to target’s build phase - copy bundle resources (if using the “out of the box” storyboards)
Drag AppPassword.framework to your application’s framework folder (accept the defaults on the pop-up dialog)
$ sudo gem install cocoapods
in your terminal. (See the CocoaPods website for details.)pod init
to create a Podfile.pod 'SecureFoundation', :git => 'https://github.com/project-imas/securefoundation.git'
to your PodFilepod 'AppPassword', :git => 'https://github.com/project-imas/app-password.git'
pod install
#import <AppPassword/AppPassword.h>
to your appThe “App Password” folder contains one key class: APPass
. It is designed as a class factory that provides either a simple or complex control for your AppViewController. The following are examples of instantiating and launching a control.
###Simple:
// ---------------------------------------------------------------
// AppPassword API - passcode
// ---------------------------------------------------------------
APPass *pass;
self.pass = [APPass passWithCodes:6 rotatingKeyboard:YES];
self.pass.delegate = self;
// ---------------------------------------------------------------
// setting the parentView will cause the passView to be displayed
// ---------------------------------------------------------------
self.pass.parentView = self.view;
###Complex:
// ---------------------------------------------------------------
// AppPassword API - passcode
// ---------------------------------------------------------------
APPass *pass;
self.pass = [APPass passComplex];
self.pass.delegate = self;
self.pass.syntax = @"^.*(?=.*[a-zA-Z])(?=.*[0-9])(?=.{6,}).*$";
self.pass.syntaxLabel = @"length:6 - 1 digit";
// ---------------------------------------------------------------
// AppPassword API - security questions
// ---------------------------------------------------------------
APPass *question;
self.numberOfQuestion = 2;
self.question = [APPass passQuestions:self.numberOfQuestion];
self.question.delegate = self;
// ---------------------------------------------------------------
// setting the parentView will cause the passView to be displayed
// ---------------------------------------------------------------
self.pass.parentView = self.view;
The APPass class allows you to specify your own storyboard with the following methods:
###Simple:
+(APPass*) passWithName:(NSString*) name
codes:(NSInteger) numberOfCodes
rotatingKeyboard:(BOOL) rotating
fromStoryboardWithName:(NSString*) storyboardName;
#####Parameters
name
The Storyboard ID e.g. APSimplePass within the framework's provided storyboard.
numberOfCodes
The number of codes (digits) that will be required to create a passcode.
rotating
A boolean that indicates whether or not to rotate the keyboard keys.
storyboardName
The storyboard's name without the extension e.g. APSimplePass_iPhone within the framework's provided storyboards.
#####Required IBOutlets
@property (nonatomic,strong) IBOutlet UILabel * phraseTitleLabel;
@property (nonatomic,strong) IBOutlet UILabel * phraseSubtitleLabel;
@property (nonatomic,strong) IBOutlet UITextField * phraseTextField;
###Complex:
+(APPass*) complexPassWithName:(NSString*) name
fromStoryboardWithName:(NSString*) storyboardName
#####Parameters
name
The Storyboard ID e.g. APComplexPass within the framework's provided storyboard.
storyboardName
The storyboard's name without the extension e.g. APComplexPass_iPhone within the framework's provided storyboards.
#####Required IBOutlets
@property (nonatomic,strong) IBOutlet UILabel * phraseTitleLabel;
@property (nonatomic,strong) IBOutlet UILabel * phraseSubtitleLabel;
@property (nonatomic,strong) IBOutlet UITextField * phraseTextField;
The sample applications demonstrate the implementation of the “out of the box” passcode controls, as well as, the implementation of the delegation methods.
Instructions for running the sample apps:
Be sure to review - AppPass Sample App
Instructions for running the sample apps:
MITRE wishes to thank Kevin O’Keefe for thoroughly revamping and re-implementing this security control from the ground up.
Copyright 2012,2013 The MITRE Corporation, All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this work except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.