* Add PKCE support. * Fix tests * Update oauth2.md * Rename usePkce * Fix the BrokenComponent error * Update oauth2.md * Remove isCode variable. Remove uuid4 dependency. * Remove utils functions * Import crypto * Fix tests * Fix the tests * Cleanup * Fix code_challenge generation * Move code challenge and verifier to utils for mocks. Update tests. * Mock the PKCE methods in the utils file properly. * Add missing expect * use target-method spies * Add comments to explain test values. * Get rid of jsrsasign.
47 lines
990 B
JavaScript
47 lines
990 B
JavaScript
const translator = require("./translator")
|
|
const indent = require("./helpers").indent
|
|
|
|
const oauthBlockSchema = {
|
|
OAUTH_CLIENT_ID: {
|
|
type: "string",
|
|
name: "clientId"
|
|
},
|
|
OAUTH_CLIENT_SECRET: {
|
|
type: "string",
|
|
name: "clientSecret",
|
|
onFound: () => console.warn("Swagger UI warning: don't use `OAUTH_CLIENT_SECRET` in production!")
|
|
},
|
|
OAUTH_REALM: {
|
|
type: "string",
|
|
name: "realm"
|
|
},
|
|
OAUTH_APP_NAME: {
|
|
type: "string",
|
|
name: "appName"
|
|
},
|
|
OAUTH_SCOPE_SEPARATOR: {
|
|
type: "string",
|
|
name: "scopeSeparator"
|
|
},
|
|
OAUTH_ADDITIONAL_PARAMS: {
|
|
type: "object",
|
|
name: "additionalQueryStringParams"
|
|
},
|
|
OAUTH_USE_PKCE: {
|
|
type: "boolean",
|
|
name: "usePkceWithAuthorizationCodeGrant"
|
|
}
|
|
}
|
|
|
|
module.exports = function oauthBlockBuilder(env) {
|
|
const translatorResult = translator(env, { schema: oauthBlockSchema })
|
|
|
|
if(translatorResult) {
|
|
return (
|
|
`ui.initOAuth({
|
|
${indent(translatorResult, 2)}
|
|
})`)
|
|
}
|
|
|
|
return ``
|
|
} |