You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
1.0 KiB

  1. const translator = require("./translator")
  2. const indent = require("./helpers").indent
  3. const oauthBlockSchema = {
  4. OAUTH_CLIENT_ID: {
  5. type: "string",
  6. name: "clientId"
  7. },
  8. OAUTH_CLIENT_SECRET: {
  9. type: "string",
  10. name: "clientSecret",
  11. onFound: () => console.warn("Swagger UI warning: don't use `OAUTH_CLIENT_SECRET` in production!")
  12. },
  13. OAUTH_REALM: {
  14. type: "string",
  15. name: "realm"
  16. },
  17. OAUTH_APP_NAME: {
  18. type: "string",
  19. name: "appName"
  20. },
  21. OAUTH_SCOPE_SEPARATOR: {
  22. type: "string",
  23. name: "scopeSeparator"
  24. },
  25. OAUTH_SCOPES: {
  26. type: "string",
  27. name: "scopes"
  28. },
  29. OAUTH_ADDITIONAL_PARAMS: {
  30. type: "object",
  31. name: "additionalQueryStringParams"
  32. },
  33. OAUTH_USE_PKCE: {
  34. type: "boolean",
  35. name: "usePkceWithAuthorizationCodeGrant"
  36. }
  37. }
  38. module.exports = function oauthBlockBuilder(env) {
  39. const translatorResult = translator(env, { schema: oauthBlockSchema })
  40. if(translatorResult) {
  41. return (
  42. `ui.initOAuth({
  43. ${indent(translatorResult, 2)}
  44. })`)
  45. }
  46. return ``
  47. }