Skip to content

Commit 21f5149

Browse files
authored
fix: support variables in auth urls (#5913)
1 parent 01fb5c0 commit 21f5149

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/core/plugins/auth/actions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ export const authorizeRequest = ( data ) => ( { fn, getConfigs, authActions, err
156156
let parsedUrl
157157

158158
if (specSelectors.isOAS3()) {
159-
parsedUrl = parseUrl(url, oas3Selectors.selectedServer(), true)
159+
const server = oas3Selectors.selectedServer()
160+
parsedUrl = parseUrl(url, oas3Selectors.serverEffectiveValue({ server }), true)
160161
} else {
161162
parsedUrl = parseUrl(url, specSelectors.url(), true)
162163
}

test/mocha/core/plugins/auth/actions.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ describe("auth plugin - actions", () => {
1414
{
1515
oas3: true,
1616
server: "https://host/resource",
17+
effectiveServer: "https://host/resource",
18+
scheme: "http",
19+
host: null,
20+
url: "http://specs/file",
21+
},
22+
"https://host/authorize"
23+
],
24+
[
25+
{
26+
oas3: true,
27+
server: "https://{selected_host}/resource",
28+
effectiveServer: "https://host/resource",
1729
scheme: "http",
1830
host: null,
1931
url: "http://specs/file",
@@ -24,6 +36,7 @@ describe("auth plugin - actions", () => {
2436
{
2537
oas3: false,
2638
server: null,
39+
effectiveServer: null,
2740
scheme: "https",
2841
host: undefined,
2942
url: "https://specs/file",
@@ -34,13 +47,14 @@ describe("auth plugin - actions", () => {
3447
{
3548
oas3: false,
3649
server: null,
50+
effectiveServer: null,
3751
scheme: "https",
3852
host: "host",
3953
url: "http://specs/file",
4054
},
4155
"http://specs/authorize"
4256
],
43-
].forEach(([{oas3, server, scheme, host, url}, expectedFetchUrl]) => {
57+
].forEach(([{oas3, server, effectiveServer, scheme, host, url}, expectedFetchUrl]) => {
4458
it("should resolve authorization endpoint against the server URL", () => {
4559

4660
// Given
@@ -56,7 +70,8 @@ describe("auth plugin - actions", () => {
5670
getConfigs: () => ({})
5771
},
5872
oas3Selectors: {
59-
selectedServer: () => server
73+
selectedServer: () => server,
74+
serverEffectiveValue: () => effectiveServer || server
6075
},
6176
specSelectors: {
6277
isOAS3: () => oas3,
@@ -130,7 +145,8 @@ describe("auth plugin - actions", () => {
130145
})
131146
},
132147
oas3Selectors: {
133-
selectedServer: () => "http://google.com"
148+
selectedServer: () => "http://google.com",
149+
serverEffectiveValue: () => "http://google.com"
134150
},
135151
specSelectors: {
136152
isOAS3: () => true,
@@ -150,13 +166,13 @@ describe("auth plugin - actions", () => {
150166

151167
describe("tokenRequest", function() {
152168
it("should send the code verifier when set", () => {
153-
const data = {
169+
const data = {
154170
auth: {
155171
schema: {
156172
get: () => "http://tokenUrl"
157173
},
158174
codeVerifier: "mock_code_verifier"
159-
},
175+
},
160176
redirectUrl: "http://google.com"
161177
}
162178

0 commit comments

Comments
 (0)