Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 2.56 KB

File metadata and controls

50 lines (35 loc) · 2.56 KB

Authentication

Level: Beginner
Technologies: Swift 4.0, iOS
Summary: A basic example of performing http basic/digest authentication using aerogear-ios-http

What is it?

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.

System requirements

  • iOS9, iOS910, iOS11
  • Xcode 9+

Configure

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.

Build and Deploy

Change URL

If you deploy the backend locally, in Network.swift, update the URL accordingly:

    static let instance = Http(baseURL: "http://localhost:8080/authentication")
...
}

Run it in Xcode

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.

Application Flow

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.

import import