测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | BSD |
发布时间最后发布 | 2017年2月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 James Barclay,Pepijn Bruienne,Mike Brown 维护。
DuoAPISwift 是一个用来用 Swift 调用 Duo API 方法的 API 客户端。
Duo 身份验证 API为不能直接显示丰富网页内容的程序提供了低级别 API,以便添加强大的双因素认证。
import DuoAPISwift
let auth = Auth(
ikey: "<IKEY>",
skey: "<SKEY (Keep this secret!)>",
host: "api-xxxxxxxx.duosecurity.com")
auth.ping({response in
print(response)
})
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
}
}
})
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.")
}
})