DuoAPISwift 2.0.0

DuoAPISwift 2.0.0

测试已测试
语言语言 SwiftSwift
许可证 BSD
发布时间最后发布2017年2月
SwiftSwift 版本3.0
SPM支持 SPM

James BarclayPepijn BruienneMike Brown 维护。



  • James Barclay,Mark Lee 和 Mike Brown

DuoAPISwift

DuoAPISwift 是一个用来用 Swift 调用 Duo API 方法的 API 客户端。

Duo 身份验证 API

Duo 身份验证 API为不能直接显示丰富网页内容的程序提供了低级别 API,以便添加强大的双因素认证。

使用方法

创建 Auth 对象

import DuoAPISwift

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

验证 Duo 是否运行正常

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

验证 IKEY, SKEY 和签名

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

检索已存储的徽标

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

发送 Duo 推送身份验证请求

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.")
    }
})