Skip to content

Commit 55d982a

Browse files
fix: launch-authenticator relatesTo work-around (#1466)
OKTA-659175 fix: launch-authenticator relatesTo work-around
1 parent ae12c07 commit 55d982a

File tree

6 files changed

+323
-2
lines changed

6 files changed

+323
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 7.4.3
4+
5+
### Bug Fix
6+
7+
- [#1466](https://github.com/okta/okta-auth-js/pull/1466) Fix: Issues with `launch-authenticator` rememdiation on safari
8+
39
## 7.4.2
410

511
### Bug Fix

lib/idx/idxState/v1/idxResponseParser.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,18 @@ export const parseIdxResponse = function parseIdxResponse( authClient: OktaAuthI
113113
const remediationData = idxResponse.remediation?.value || [];
114114

115115
remediationData.forEach(
116-
remediation => expandRelatesTo(idxResponse, remediation)
116+
remediation => {
117+
// TODO: remove once IDX is fixed - OKTA-659181
118+
if (remediation.name === 'launch-authenticator' &&
119+
remediation?.relatesTo?.[0] === 'authenticatorChallenge' &&
120+
!idxResponse?.authenticatorChallenge
121+
) {
122+
delete remediation.relatesTo;
123+
return;
124+
}
125+
126+
return expandRelatesTo(idxResponse, remediation);
127+
}
117128
);
118129

119130
const remediations = remediationData.map(remediation => convertRemediationAction( authClient, remediation, toPersist ));

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "@okta/okta-auth-js",
44
"description": "The Okta Auth SDK",
5-
"version": "7.4.2",
5+
"version": "7.4.3",
66
"homepage": "https://github.com/okta/okta-auth-js",
77
"license": "Apache-2.0",
88
"main": "build/cjs/exports/default.js",
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"version": "1.0.0",
3+
"stateHandle": "stateHandle",
4+
"expiresAt": "2023-10-18T18:18:41.000Z",
5+
"intent": "LOGIN",
6+
"remediation": {
7+
"type": "array",
8+
"value": [
9+
{
10+
"rel": [
11+
"create-form"
12+
],
13+
"name": "identify",
14+
"href": "http://localhost:3000.com/idp/idx/identify",
15+
"method": "POST",
16+
"produces": "application/ion+json; okta-version=1.0.0",
17+
"value": [
18+
{
19+
"name": "identifier",
20+
"label": "Username",
21+
"required": true
22+
},
23+
{
24+
"name": "rememberMe",
25+
"type": "boolean",
26+
"label": "Remember this device"
27+
},
28+
{
29+
"name": "stateHandle",
30+
"required": true,
31+
"value": "stateHande",
32+
"visible": false,
33+
"mutable": false
34+
}
35+
],
36+
"accepts": "application/json; okta-version=1.0.0"
37+
},
38+
{
39+
"rel": [
40+
"create-form"
41+
],
42+
"name": "launch-authenticator",
43+
"relatesTo": [
44+
"authenticatorChallenge"
45+
],
46+
"href": "http://localhost:3000.com/idp/idx/authenticators/okta-verify/launch",
47+
"method": "POST",
48+
"produces": "application/ion+json; okta-version=1.0.0",
49+
"value": [
50+
{
51+
"name": "rememberMe",
52+
"type": "boolean",
53+
"label": "Remember this device"
54+
},
55+
{
56+
"name": "stateHandle",
57+
"required": true,
58+
"value": "stateHande",
59+
"visible": false,
60+
"mutable": false
61+
}
62+
],
63+
"accepts": "application/json; okta-version=1.0.0"
64+
},
65+
{
66+
"rel": [
67+
"create-form"
68+
],
69+
"name": "select-enroll-profile",
70+
"href": "http://localhost:3000.com/idp/idx/enroll",
71+
"method": "POST",
72+
"produces": "application/ion+json; okta-version=1.0.0",
73+
"value": [
74+
{
75+
"name": "stateHandle",
76+
"required": true,
77+
"value": "stateHande",
78+
"visible": false,
79+
"mutable": false
80+
}
81+
],
82+
"accepts": "application/json; okta-version=1.0.0"
83+
}
84+
]
85+
},
86+
"cancel": {
87+
"rel": [
88+
"create-form"
89+
],
90+
"name": "cancel",
91+
"href": "http://localhost:3000.com/idp/idx/cancel",
92+
"method": "POST",
93+
"produces": "application/ion+json; okta-version=1.0.0",
94+
"value": [
95+
{
96+
"name": "stateHandle",
97+
"required": true,
98+
"value": "stateHande",
99+
"visible": false,
100+
"mutable": false
101+
}
102+
],
103+
"accepts": "application/json; okta-version=1.0.0"
104+
},
105+
"app": {
106+
"type": "object",
107+
"value": {
108+
"name": "okta_enduser",
109+
"label": "Okta Dashboard",
110+
"id": "srhgsefasef"
111+
}
112+
},
113+
"authentication": {
114+
"type": "object",
115+
"value": {
116+
"protocol": "OAUTH2.0",
117+
"issuer": {
118+
"name": "Mock",
119+
"uri": "http://localhost:3000.com"
120+
},
121+
"request": {
122+
"max_age": -1,
123+
"scope": "openid profile email",
124+
"display": "page",
125+
"response_type": "code",
126+
"redirect_uri": "http://localhost:3000.com/enduser/callback",
127+
"state": "stateValue",
128+
"code_challenge_method": "S256",
129+
"nonce": "nonceValue",
130+
"code_challenge": "code_challenge",
131+
"response_mode": "query"
132+
}
133+
}
134+
},
135+
"authenticatorChallenge": {
136+
"type": "object",
137+
"value": {
138+
"challengeMethod": "CUSTOM_URI",
139+
"href": "http://localhost:3000/foobar",
140+
"downloadHref": "http://localhost:3000/foobar"
141+
}
142+
}
143+
}
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"version": "1.0.0",
3+
"stateHandle": "stateHandle",
4+
"expiresAt": "2023-10-18T18:18:41.000Z",
5+
"intent": "LOGIN",
6+
"remediation": {
7+
"type": "array",
8+
"value": [
9+
{
10+
"rel": [
11+
"create-form"
12+
],
13+
"name": "identify",
14+
"href": "http://localhost:3000.com/idp/idx/identify",
15+
"method": "POST",
16+
"produces": "application/ion+json; okta-version=1.0.0",
17+
"value": [
18+
{
19+
"name": "identifier",
20+
"label": "Username",
21+
"required": true
22+
},
23+
{
24+
"name": "rememberMe",
25+
"type": "boolean",
26+
"label": "Remember this device"
27+
},
28+
{
29+
"name": "stateHandle",
30+
"required": true,
31+
"value": "stateHande",
32+
"visible": false,
33+
"mutable": false
34+
}
35+
],
36+
"accepts": "application/json; okta-version=1.0.0"
37+
},
38+
{
39+
"rel": [
40+
"create-form"
41+
],
42+
"name": "launch-authenticator",
43+
"relatesTo": [
44+
"authenticatorChallenge"
45+
],
46+
"href": "http://localhost:3000.com/idp/idx/authenticators/okta-verify/launch",
47+
"method": "POST",
48+
"produces": "application/ion+json; okta-version=1.0.0",
49+
"value": [
50+
{
51+
"name": "rememberMe",
52+
"type": "boolean",
53+
"label": "Remember this device"
54+
},
55+
{
56+
"name": "stateHandle",
57+
"required": true,
58+
"value": "stateHande",
59+
"visible": false,
60+
"mutable": false
61+
}
62+
],
63+
"accepts": "application/json; okta-version=1.0.0"
64+
},
65+
{
66+
"rel": [
67+
"create-form"
68+
],
69+
"name": "select-enroll-profile",
70+
"href": "http://localhost:3000.com/idp/idx/enroll",
71+
"method": "POST",
72+
"produces": "application/ion+json; okta-version=1.0.0",
73+
"value": [
74+
{
75+
"name": "stateHandle",
76+
"required": true,
77+
"value": "stateHande",
78+
"visible": false,
79+
"mutable": false
80+
}
81+
],
82+
"accepts": "application/json; okta-version=1.0.0"
83+
}
84+
]
85+
},
86+
"cancel": {
87+
"rel": [
88+
"create-form"
89+
],
90+
"name": "cancel",
91+
"href": "http://localhost:3000.com/idp/idx/cancel",
92+
"method": "POST",
93+
"produces": "application/ion+json; okta-version=1.0.0",
94+
"value": [
95+
{
96+
"name": "stateHandle",
97+
"required": true,
98+
"value": "stateHande",
99+
"visible": false,
100+
"mutable": false
101+
}
102+
],
103+
"accepts": "application/json; okta-version=1.0.0"
104+
},
105+
"app": {
106+
"type": "object",
107+
"value": {
108+
"name": "okta_enduser",
109+
"label": "Okta Dashboard",
110+
"id": "srhgsefasef"
111+
}
112+
},
113+
"authentication": {
114+
"type": "object",
115+
"value": {
116+
"protocol": "OAUTH2.0",
117+
"issuer": {
118+
"name": "Mock",
119+
"uri": "http://localhost:3000.com"
120+
},
121+
"request": {
122+
"max_age": -1,
123+
"scope": "openid profile email",
124+
"display": "page",
125+
"response_type": "code",
126+
"redirect_uri": "http://localhost:3000.com/enduser/callback",
127+
"state": "stateValue",
128+
"code_challenge_method": "S256",
129+
"nonce": "nonceValue",
130+
"code_challenge": "code_challenge",
131+
"response_mode": "query"
132+
}
133+
}
134+
}
135+
}

test/spec/idx/idxState/unit/v1/idxResponseParser.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ const mockComplexContextIdxResponse = require('../../mocks/poll-for-password');
2121
const mockTerminalIdxResponse = require('../../mocks/terminal-return-email');
2222
const mockMessageIdxResponse = require('../../mocks/unknown-user');
2323
const mockSuccessIdxResponse = require('../../mocks/success');
24+
// TODO: OKTA-659181
25+
const mockSafariRelatesToResponse = require('../../mocks/safari-relatesTo-response');
26+
const mockResponseWithFix = require('../../mocks/safari-relatesTo-fixed-response');
27+
2428
const mockIdxResponseWithBadRelationship = () => {
2529
const mock = require('../../mocks/authenticator-verification-password');
2630
mock.remediation.value[1].value[0].options[0].relatesTo = '$.authenticatorEnrollments.value[999]';
@@ -173,5 +177,27 @@ describe('idxResponseParser', () => {
173177
const fn = () => parseIdxResponse( {}, mockIdxResponseWithBadRelationship() );
174178
expect(fn).toThrowError('Cannot resolve relatesTo: $.authenticatorEnrollments.value[999]');
175179
});
180+
181+
// TODO: OKTA-659181
182+
describe('OKTA-659175', () => {
183+
it('removes `relatesTo` when reference is invalid', () => {
184+
const { remediations } = parseIdxResponse({}, mockSafariRelatesToResponse, {});
185+
expect(remediations[1].name).toEqual('launch-authenticator');
186+
expect(remediations[1].relatesTo).toBeUndefined();
187+
});
188+
189+
it('resolves `relatesTo` when reference is valid', () => {
190+
const { remediations } = parseIdxResponse({}, mockResponseWithFix, {});
191+
expect(remediations[1].name).toEqual('launch-authenticator');
192+
expect(remediations[1].relatesTo).toEqual({
193+
'type': 'object',
194+
'value': {
195+
'challengeMethod': 'CUSTOM_URI',
196+
'href': 'http://localhost:3000/foobar',
197+
'downloadHref': 'http://localhost:3000/foobar'
198+
}
199+
});
200+
});
201+
});
176202
});
177203
});

0 commit comments

Comments
 (0)