Skip to content

Commit

Permalink
Duo Passcode Prepend (#18342)
Browse files Browse the repository at this point in the history
* prepends passcode= for duo totp mfa method

* adds changelog entry
  • Loading branch information
zofskeez committed Dec 13, 2022
1 parent b4b08fc commit 96696b8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelog/18342.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Prepends "passcode=" if not provided in user input for duo totp mfa method authentication
```
12 changes: 11 additions & 1 deletion ui/app/adapters/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,17 @@ export default ApplicationAdapter.extend({
data: {
mfa_request_id,
mfa_payload: mfa_constraints.reduce((obj, { selectedMethod, passcode }) => {
obj[selectedMethod.id] = passcode ? [passcode] : [];
let payload = [];
if (passcode) {
// duo requires passcode= prepended to the actual passcode
// this isn't a great UX so we add it behind the scenes to fulfill the requirement
// check if user added passcode= to avoid duplication
payload =
selectedMethod.type === 'duo' && !passcode.includes('passcode=')
? [`passcode=${passcode}`]
: [passcode];
}
obj[selectedMethod.id] = payload;
return obj;
}, {}),
},
Expand Down
2 changes: 2 additions & 0 deletions ui/mirage/handlers/mfa.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default function (server) {
[mfa_constraints, methods] = generator([m('okta'), m('totp')], [m('totp')]); // 2 constraints 1 passcode/1 non-passcode 1 non-passcode
} else if (user === 'mfa-j') {
[mfa_constraints, methods] = generator([m('pingid')]); // use to test push failures
} else if (user === 'mfa-k') {
[mfa_constraints, methods] = generator([m('duo', true)]); // test duo passcode and prepending passcode= to user input
}
const numbers = (length) =>
Math.random()
Expand Down
2 changes: 1 addition & 1 deletion ui/tests/integration/components/mfa-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module('Integration | Component | mfa-form', function (hooks) {
const json = JSON.parse(req.requestBody);
const payload = {
mfa_request_id: 'test-mfa-id',
mfa_payload: { [oktaConstraint.id]: [], [duoConstraint.id]: ['test-code'] },
mfa_payload: { [oktaConstraint.id]: [], [duoConstraint.id]: ['passcode=test-code'] },
};
assert.deepEqual(json, payload, 'Correct mfa payload passed to validate endpoint');
return {};
Expand Down

0 comments on commit 96696b8

Please sign in to comment.