Skip to content

Commit c624323

Browse files
author
Yvo
authored
Merge pull request go-auth0#225 from JayHelton/issue-224-support-webauthn
Issue 224: adding support webauthn roaming and platform
2 parents 67ed4ed + e0d9b42 commit c624323

File tree

3 files changed

+72
-6
lines changed

3 files changed

+72
-6
lines changed

management/guardian.go

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ func newGuardianManager(m *Management) *GuardianManager {
9898
&MultiFactorEmail{m},
9999
&MultiFactorDUO{m},
100100
&MultiFactorOTP{m},
101+
&MultiFactorWebAuthnRoaming{m},
102+
&MultiFactorWebAuthnPlatform{m},
101103
},
102104
}
103105
}
@@ -166,12 +168,14 @@ func (m *EnrollmentManager) Delete(id string, opts ...RequestOption) (err error)
166168

167169
type MultiFactorManager struct {
168170
*Management
169-
Phone *MultiFactorPhone
170-
SMS *MultiFactorSMS
171-
Push *MultiFactorPush
172-
Email *MultiFactorEmail
173-
DUO *MultiFactorDUO
174-
OTP *MultiFactorOTP
171+
Phone *MultiFactorPhone
172+
SMS *MultiFactorSMS
173+
Push *MultiFactorPush
174+
Email *MultiFactorEmail
175+
DUO *MultiFactorDUO
176+
OTP *MultiFactorOTP
177+
WebAuthnRoaming *MultiFactorWebAuthnRoaming
178+
WebAuthnPlatform *MultiFactorWebAuthnPlatform
175179
}
176180

177181
// Retrieves all factors.
@@ -330,6 +334,28 @@ func (m *MultiFactorDUO) Enable(enabled bool, opts ...RequestOption) error {
330334
}, opts...)
331335
}
332336

337+
type MultiFactorWebAuthnRoaming struct{ *Management }
338+
339+
// Enable enables or disables WebAuthn Roaming Multi-factor Authentication.
340+
//
341+
// See: https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name
342+
func (m *MultiFactorWebAuthnRoaming) Enable(enabled bool, opts ...RequestOption) error {
343+
return m.Request("PUT", m.URI("guardian", "factors", "webauthn-roaming"), &MultiFactor{
344+
Enabled: &enabled,
345+
}, opts...)
346+
}
347+
348+
type MultiFactorWebAuthnPlatform struct{ *Management }
349+
350+
// Enable enables or disables WebAuthn Platform Multi-factor Authentication.
351+
//
352+
// See: https://auth0.com/docs/api/management/v2#!/Guardian/put_factors_by_name
353+
func (m *MultiFactorWebAuthnPlatform) Enable(enabled bool, opts ...RequestOption) error {
354+
return m.Request("PUT", m.URI("guardian", "factors", "webauthn-roaming"), &MultiFactor{
355+
Enabled: &enabled,
356+
}, opts...)
357+
}
358+
333359
type MultiFactorOTP struct{ *Management }
334360

335361
// Enable enables or disables One-time Password Multi-factor Authentication.

management/guardian_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,36 @@ func TestGuardian(t *testing.T) {
205205
t.Logf("%v\n", mfa)
206206
})
207207
})
208+
209+
t.Run("WebAuthn Roaming", func(t *testing.T) {
210+
211+
t.Run("Enable", func(t *testing.T) {
212+
defer m.Guardian.MultiFactor.WebAuthnRoaming.Enable(false)
213+
214+
err := m.Guardian.MultiFactor.WebAuthnRoaming.Enable(true)
215+
if err != nil {
216+
t.Error(err)
217+
}
218+
219+
mfa, _ := m.Guardian.MultiFactor.List()
220+
t.Logf("%v\n", mfa)
221+
})
222+
})
223+
224+
t.Run("WebAuthn Platform", func(t *testing.T) {
225+
226+
t.Run("Enable", func(t *testing.T) {
227+
defer m.Guardian.MultiFactor.WebAuthnPlatform.Enable(false)
228+
229+
err := m.Guardian.MultiFactor.WebAuthnPlatform.Enable(true)
230+
if err != nil {
231+
t.Error(err)
232+
}
233+
234+
mfa, _ := m.Guardian.MultiFactor.List()
235+
t.Logf("%v\n", mfa)
236+
})
237+
})
208238
})
209239

210240
t.Run("Enrollment", func(t *testing.T) {

management/management.gen.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)