-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for FACTOR_ENROLL state. (#196)
- Adds support for FACTOR_ENROLL state in auth js. Resolves: OKTA-215034
- Loading branch information
1 parent
1ca7e02
commit dde3dfb
Showing
4 changed files
with
295 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
var util = require('../util/util'), | ||
_ = require('lodash'); | ||
|
||
describe('FACTOR_ENROLL', function () { | ||
describe('factors', function () { | ||
describe('factor.questions', function () { | ||
util.itMakesCorrectRequestResponse({ | ||
setup: { | ||
status: 'factor-enroll', | ||
request: { | ||
method: 'get', | ||
uri: '/api/v1/users/00uoy3CXZHSMMJPHYXXP/factors/questions' | ||
}, | ||
response: 'questions' | ||
}, | ||
execute: function (test) { | ||
var factor = _.find(test.trans.factors, { | ||
factorType: 'question', | ||
provider: 'OKTA' | ||
}); | ||
return factor.questions(); | ||
}, | ||
expectations: function (test, res) { | ||
expect(test.resReply.status).toEqual(200); | ||
expect(test.responseBody).toEqual(res); | ||
} | ||
}); | ||
}); | ||
|
||
describe('factor.enroll', function () { | ||
util.itMakesCorrectRequestResponse({ | ||
title: 'enrolls with updatePhone', | ||
setup: { | ||
status: 'factor-enroll', | ||
request: { | ||
uri: '/api/v1/authn/factors?updatePhone=true', | ||
data: { | ||
stateToken: '01Z20ZhXVrmyR3z8R-m77BvknHyckWCy5vNwEA6huD', | ||
factorType: 'sms', | ||
provider: 'OKTA', | ||
profile: { | ||
phoneNumber: '+1-555-415-1337' | ||
} | ||
} | ||
}, | ||
response: 'factor-enroll-activate-sms' | ||
}, | ||
execute: function (test) { | ||
var factor = _.find(test.trans.factors, { | ||
factorType: 'sms', | ||
provider: 'OKTA' | ||
}); | ||
return factor.enroll({ | ||
profile: { | ||
phoneNumber: '+1-555-415-1337', | ||
updatePhone: true | ||
} | ||
}); | ||
} | ||
}); | ||
util.itMakesCorrectRequestResponse({ | ||
setup: { | ||
status: 'factor-enroll', | ||
request: { | ||
uri: '/api/v1/authn/factors', | ||
data: { | ||
stateToken: '01Z20ZhXVrmyR3z8R-m77BvknHyckWCy5vNwEA6huD', | ||
factorType: 'sms', | ||
provider: 'OKTA', | ||
profile: { | ||
phoneNumber: '+1-555-415-1337' | ||
} | ||
} | ||
}, | ||
response: 'factor-enroll-activate-sms' | ||
}, | ||
execute: function (test) { | ||
var factor = _.find(test.trans.factors, { | ||
factorType: 'sms', | ||
provider: 'OKTA' | ||
}); | ||
return factor.enroll({ | ||
profile: { | ||
phoneNumber: '+1-555-415-1337' | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
describe('trans.cancel', function () { | ||
util.itMakesCorrectRequestResponse({ | ||
setup: { | ||
status: 'factor-enroll', | ||
request: { | ||
uri: '/api/v1/authn/cancel', | ||
data: { | ||
stateToken: '01Z20ZhXVrmyR3z8R-m77BvknHyckWCy5vNwEA6huD' | ||
} | ||
}, | ||
response: 'cancel' | ||
}, | ||
execute: function (test) { | ||
return test.trans.cancel(); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
module.exports = { | ||
"status": 200, | ||
"responseType": "json", | ||
"response": { | ||
"stateToken": "01lT7DEzQaeP6mv1_y3pdXjNEONzk83mXX-yhgEdVQ", | ||
"expiresAt": "2014-11-03T00:46:09.700Z", | ||
"status": "FACTOR_ENROLL_ACTIVATE", | ||
"relayState": "/myapp/some/deep/link/i/want/to/return/to", | ||
"_embedded": { | ||
"user": { | ||
"id": "00ub0oNGTSWTBKOLGLNR", | ||
"profile": { | ||
"login": "[email protected]", | ||
"firstName": "Isaac", | ||
"lastName": "Brock", | ||
"locale": "en_US", | ||
"timeZone": "America/Los_Angeles" | ||
} | ||
}, | ||
"factor": { | ||
"id": "mbl198rKSEWOSKRIVIFT", | ||
"factorType": "sms", | ||
"provider": "OKTA", | ||
"profile": { | ||
"phoneNumber": "+1 XXX-XXX-1337" | ||
} | ||
} | ||
}, | ||
"_links": { | ||
"next": { | ||
"name": "activate", | ||
"href": "<%= uri %>/api/v1/authn/factors/mbl198rKSEWOSKRIVIFT/lifecycle/activate", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
}, | ||
"cancel": { | ||
"href": "<%= uri %>/api/v1/authn/cancel", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
}, | ||
"prev": { | ||
"href": "<%= uri %>/api/v1/authn/previous", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
}, | ||
"resend": [{ | ||
"name": "sms", | ||
"href": "<%= uri %>/api/v1/authn/factors/mbl198rKSEWOSKRIVIFT/lifecycle/resend", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
}] | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
module.exports = { | ||
"status": 200, | ||
"responseType": "json", | ||
"response": { | ||
"stateToken": "01Z20ZhXVrmyR3z8R-m77BvknHyckWCy5vNwEA6huD", | ||
"expiresAt": "2014-11-02T23:44:41.736Z", | ||
"status": "FACTOR_ENROLL", | ||
"relayState": "/myapp/some/deep/link/i/want/to/return/to", | ||
"_embedded": { | ||
"user": { | ||
"id": "00ub0oNGTSWTBKOLGLNR", | ||
"profile": { | ||
"login": "[email protected]", | ||
"firstName": "Isaac", | ||
"lastName": "Brock", | ||
"locale": "en_US", | ||
"timeZone": "America/Los_Angeles" | ||
} | ||
}, | ||
"factors": [{ | ||
"factorType": "question", | ||
"provider": "OKTA", | ||
"_links": { | ||
"questions": { | ||
"href": "<%= uri %>/api/v1/users/00uoy3CXZHSMMJPHYXXP/factors/questions", | ||
"hints": { | ||
"allow": [ | ||
"GET" | ||
] | ||
} | ||
}, | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}, { | ||
"factorType": "token", | ||
"provider": "RSA", | ||
"_links": { | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}, { | ||
"factorType": "token:software:totp", | ||
"provider": "GOOGLE", | ||
"_links": { | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}, { | ||
"factorType": "token:software:totp", | ||
"provider": "OKTA", | ||
"_links": { | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}, { | ||
"factorType": "sms", | ||
"provider": "OKTA", | ||
"_links": { | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}, { | ||
"factorType": "push", | ||
"provider": "OKTA", | ||
"_links": { | ||
"enroll": { | ||
"href": "<%= uri %>/api/v1/authn/factors", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
}] | ||
}, | ||
"_links": { | ||
"cancel": { | ||
"href": "<%= uri %>/api/v1/authn/cancel", | ||
"hints": { | ||
"allow": [ | ||
"POST" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
}; |