Level: Beginner
Technologies: Swift 4.0, iOS
Summary: A basic example of performing http basic/digest authentication using aerogear-ios-http
This project is a very simple app, to show how to perform an HTTP Basic/Digest authentication against a simple REST endpoint. The demo is implemented in Swift and uses the aerogear-ios-http library. Backend REST endpoint is implemented in this repo. For convenience an OpenShift instance has been deployed and the demo has been preconfigured to use it. Please make sure it is not idle before running the app, by hitting the URL in your browser.
- iOS9, iOS910, iOS11
- Xcode 9+
Either run a backend instance locally or use the OpenShift instance . To verify that the server is indeed running, click here (user: john
pass:123
) for the HTTP Basic protected endpoint, or click here (user: agnes
pass: 123
) for the HTTP Digest authentication endpoint.
NOTE: It is advised that HTTPS should be used by default when performing authentication of this type. For convenience of deployment, in this example we use HTTP in the backend example but you should opt to enable HTTPS in your application server of choice.
If you deploy the backend locally, in Network.swift, update the URL accordingly:
static let instance = Http(baseURL: "http://localhost:8080/authentication")
...
}
The project uses CocoaPods for handling its dependencies. As a pre-requisite, install CocoaPods and then install the pod. On the root directory of the project run:
pod install
and then double click on the generated .xcworkspace to open in Xcode.
When the application is launched, you will be presented with two tabs in which the former fetches data after performing HTTP basic and the latter after performing HTTP digest.