All Projects → duosecurity → duo_api_swift

duosecurity / duo_api_swift

Licence: other
Duo Security API Client for Swift

Programming Languages

objective c
16641 projects - #2 most used programming language
swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to duo api swift

EFIgy-GUI
A Mac app that uses the Duo Labs EFIgy API to inform you about the state of your EFI firmware.
Stars: ✭ 37 (+76.19%)
Mutual labels:  duo
duo go
An implementation of the Duo Security Web SDK in Go/Golang.
Stars: ✭ 12 (-42.86%)
Mutual labels:  duo
openconnect-gui-menu-bar
OpenConnect Menu Bar - Connect/Disconnect/Status - for Mac OS X (supports Duo push/sms/phone, or Yubikey, Google Authenticator, Duo, or any TOTP)
Stars: ✭ 56 (+166.67%)
Mutual labels:  duo
gofwd
A cross-platform TCP port forwarder with Duo 2FA and Geo-IP integration
Stars: ✭ 26 (+23.81%)
Mutual labels:  duo
ucsf-vpn
Linux command-line client to manage a UCSF VPN connection
Stars: ✭ 30 (+42.86%)
Mutual labels:  duo

DuoAPISwift

Build Status CocoaPods Compatible Carthage Compatible GitHub license Issues Forks Stars

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

If you have a feature request or a bug to report, please contact [email protected].

Otherwise, if you have specific questions about how to use this library or want to make it better, please open an issue here in Github or submit a pull request as needed. We do not have ETA's on when pull requests will get merged in, but we will do our best to take a look at them as soon as possible.

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.

Installation

TLS 1.2 and 1.3 Support

All recent releases of the various Apple OSes support TLS 1.2 and 1.3.

CocoaPods

To install DuoAPISwift with CocoaPods, add the following line to your Podfile.

pod 'DuoAPISwift', '~> 2.0'

Then run pod install to add DuoAPISwift to your project.

Carthage

To install DuoAPISwift with Carthage, add the following to your Cartfile.

github "duosecurity/duo_api_swift" ~> 2.0

Then run carthage update to build the framework. When finished, drag DuoAPISwift.framework to your Xcode project.

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 as 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"] as? [String : Any],
            let result = r["result"] as? String {
        if result == "allow" {
            allowed = true
        }
    }
    if allowed {
        print("Success. Logging you in...")
    } else {
        print("Access denied.")
    }
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].