Skip to content

Commit

Permalink
using duo as remediation
Browse files Browse the repository at this point in the history
  • Loading branch information
sameh0 committed Nov 23, 2023
1 parent ec89516 commit e6063a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Sources/OktaIdx/Capabilities/IDXCapability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ extension Remediation: CapabilityCollection {
///
/// This value will only be present for social IDP remediation options, and will otherwise be `nil`.
public var socialIdp: Capability.SocialIDP? { capability(Capability.SocialIDP.self) }

/// This value will only be present for Duo MFA, otherwise will be `nil`.
public var duo: Capability.Duo? { capability(Capability.Duo.self) }
}
4 changes: 3 additions & 1 deletion Sources/OktaIdx/Capabilities/IDXDuoCapability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import Foundation

extension Capability {
/// Capability to access data related to Duo
public struct Duo: AuthenticatorCapability {
public struct Duo: AuthenticatorCapability,RemediationCapability {
public let host: String
public let signedToken: String
public let script: String

let answerField: Remediation.Form.Field?
}
}
2 changes: 1 addition & 1 deletion Sources/OktaIdx/IDXForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension Remediation {

/// The array of ordered user-visible fields within this form. Each field may also contain nested forms for collections of related fields.
public let fields: [Field]
public let hiddenFields: [Field]
let hiddenFields: [Field]
let allFields: [Field]

init?(fields: [Field]?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,21 @@ extension Capability.Duo {
else {
return nil
}
self.init(host: host, signedToken: signedToken, script: script)
self.init(host: host, signedToken: signedToken, script: script, answerField: nil)
}

init?(form: Remediation.Form, object: IonForm) {
let type = Remediation.RemediationType(string: object.name)
guard type == .challengeAuthenticator else { // TODO: Find more ways to check this is Duo
return nil
}

let field = form.hiddenFields.first
self.init(host: "", signedToken: "", script: "", answerField: field)
}

func send(signature data:String) {
answerField?.value = data
}
}

Expand Down Expand Up @@ -472,7 +486,8 @@ extension Remediation {

let capabilities: [RemediationCapability?] = createCapabilities ? [
Capability.SocialIDP(flow: flow, ion: object),
Capability.Pollable(flow: flow, ion: object)
Capability.Pollable(flow: flow, ion: object),
Capability.Duo(form: form, object: object)
] : []

return Remediation(flow: flow,
Expand Down

0 comments on commit e6063a9

Please sign in to comment.