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.
 
 
 
 

43 lines
899 B

  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_ADDITIONAL_PARAMS: {
  26. type: "object",
  27. name: "additionalQueryStringParams"
  28. }
  29. }
  30. module.exports = function oauthBlockBuilder(env) {
  31. const translatorResult = translator(env, { schema: oauthBlockSchema })
  32. if(translatorResult) {
  33. return (
  34. `ui.initOAuth({
  35. ${indent(translatorResult, 2)}
  36. })`)
  37. }
  38. return ``
  39. }