CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

DuoAPISwift 2.0.0

DuoAPISwift 2.0.0

TestsTested
LangLanguage SwiftSwift
License BSD
ReleasedLast Release Feb 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by James Barclay, Pepijn Bruienne, Mike Brown.



  • By
  • James Barclay, Mark Lee and Mike Brown

DuoAPISwift

DuoAPISwift is an API client to call Duo API methods with Swift.

Duo Auth API

The Duo Auth API provides a low-level API for adding strong two-factor authentication to applications that cannot directly display rich web content.

Usage

Creating the Auth Object

import DuoAPISwift

let auth = Auth(
    ikey: "<IKEY>",
    skey: "<SKEY (Keep this secret!)>",
    host: "api-xxxxxxxx.duosecurity.com")

Verify that Duo Is Up and Running

auth.ping({response in
    print(response)
})

Verify IKEY, SKEY, and Signature

auth.check({response in
    print(response)
})

Retrieve Stored Logo

auth.logo({ response in
    if let data = response as? NSData {
        if let image = NSImage(data: data) {
            self.logoImageView.image = image
        }
    }
})

Send a Duo Push Authentication Request

auth.auth("push",
          username: "<USERNAME>",
          device: "auto",
          completion: { response in
    var allowed = false
    if let r = response["response"],
           result = r?["result"] as? String {
        if result == "allow" {
            allowed = true
        }
    }
    if allowed {
        print("Success. Logging you in...")
    } else {
        print("Access denied.")
    }
})