github.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <form action="/_api/admin/security/passport-github" method="post" class="form-horizontal passportStrategy" id="githubSetting" role="form"
  2. {% if isRestartingServerNeeded %}style="opacity: 0.4;"{% endif %}>
  3. <legend class="alert-anchor">{{ t("security_setting.OAuth.GitHub.name") }}{{ t("security_setting.configuration") }}</legend>
  4. {% set nameForIsGitHubEnabled = "settingForm[security:passport-github:isEnabled]" %}
  5. {% set isGitHubEnabled = settingForm['security:passport-github:isEnabled'] %}
  6. <div class="form-group">
  7. <label for="{{nameForIsGitHubEnabled}}" class="col-xs-3 control-label">{{ t("security_setting.OAuth.GitHub.name") }}</label>
  8. <div class="col-xs-6">
  9. <div class="btn-group btn-toggle" data-toggle="buttons">
  10. <label class="btn btn-default btn-rounded btn-outline {% if isGitHubEnabled %}active{% endif %}" data-active-class="primary">
  11. <input name="{{nameForIsGitHubEnabled}}" value="true" type="radio"
  12. {% if true === isGitHubEnabled %}checked{% endif %}> ON
  13. </label>
  14. <label class="btn btn-default btn-rounded btn-outline {% if !isGitHubEnabled %}active{% endif %}" data-active-class="default">
  15. <input name="{{nameForIsGitHubEnabled}}" value="false" type="radio"
  16. {% if !isGitHubEnabled %}checked{% endif %}> OFF
  17. </label>
  18. </div>
  19. </div>
  20. </div>
  21. <fieldset id="passport-github-hide-when-disabled" {%if !isGitHubEnabled %}style="display: none;"{% endif %}>
  22. <div class="form-group">
  23. <label for="settingForm[security:passport-github:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  24. <div class="col-xs-6">
  25. <input class="form-control" type="text" name="settingForm[security:passport-github:clientId]" value="{{ settingForm['security:passport-github:clientId'] || '' }}">
  26. <p class="help-block">
  27. <small>
  28. {{ t("security_setting.Use env var if empty", "OAUTH_GITHUB_CLIENT_SECRET") }}
  29. </small>
  30. </p>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label for="settingForm[security:passport-github:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  35. <div class="col-xs-6">
  36. <input class="form-control" type="text" name="settingForm[security:passport-github:clientSecret]" value="{{ settingForm['security:passport-github:clientSecret'] || '' }}">
  37. <p class="help-block">
  38. <small>
  39. {{ t("security_setting.Use env var if empty", "OAUTH_GITHUB_CLIENT_SECRET") }}
  40. </small>
  41. </p>
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label for="settingForm[security:passport-github:callbackURL]" class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  46. <div class="col-xs-6">
  47. <input class="form-control" type="text" name="settingForm[security:passport-github:callbackURL]" value="{{ settingForm['security:passport-github:callbackURL'] || '' }}">
  48. <p class="help-block">
  49. <small>
  50. {{ t("security_setting.Use env var if empty", "OAUTH_GITHUB_CALLBACK_URL") }}
  51. </small>
  52. </p>
  53. </div>
  54. </div>
  55. <div class="form-group">
  56. <div class="col-xs-6 col-xs-offset-3">
  57. <div class="checkbox checkbox-info">
  58. <input type="checkbox" id="bindByUserName-GitHub" name="settingForm[security:passport-github:isSameUsernameTreatedAsIdenticalUser]" value="1"
  59. {% if settingForm['security:passport-github:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  60. <label for="bindByUserName-GitHub">
  61. {{ t("security_setting.Treat username matching as identical", "username") }}
  62. </label>
  63. <p class="help-block">
  64. <small>
  65. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  66. </small>
  67. </p>
  68. </div>
  69. </div>
  70. </div>
  71. </fieldset>
  72. <div class="form-group" id="btn-update">
  73. <div class="col-xs-offset-3 col-xs-6">
  74. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  75. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  76. </div>
  77. </div>
  78. </form>
  79. {# Help Section #}
  80. <hr>
  81. <h4>
  82. <i class="fa fa-question-circle" aria-hidden="true"></i>
  83. <a href="#collapseHelpForGithubOauth" data-toggle="collapse">How to configure GitHub OAuth?</a>
  84. </h4>
  85. <ol id="collapseHelpForGithubOauth" class="collapse">
  86. <li>{{ t("security_setting.OAuth.GitHub.register_1", "https://github.com/settings/developers", "GitHub Developer Settings") }}</li>
  87. <li>{{ t("security_setting.OAuth.GitHub.register_2", "https://${growi.host}/passport/github/callback", "${growi.host}") }}</li>
  88. <li>{{ t("security_setting.OAuth.GitHub.register_3") }}</li>
  89. </ol>
  90. <script>
  91. $('input[name="settingForm[security:passport-github:isEnabled]"]').change(function() {
  92. const isEnabled = ($(this).val() === "true");
  93. if (isEnabled) {
  94. $('#passport-github-hide-when-disabled').show(400);
  95. }
  96. else {
  97. $('#passport-github-hide-when-disabled').hide(400);
  98. }
  99. });
  100. </script>