github.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. </div>
  27. </div>
  28. <div class="form-group">
  29. <label for="settingForm[security:passport-github:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  30. <div class="col-xs-6">
  31. <input class="form-control" type="text" name="settingForm[security:passport-github:clientSecret]" value="{{ settingForm['security:passport-github:clientSecret'] || '' }}">
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <div class="col-xs-6 col-xs-offset-3">
  36. <div class="checkbox checkbox-info">
  37. <input type="checkbox" id="bindByUserName-GitHub" name="settingForm[security:passport-github:isSameUsernameTreatedAsIdenticalUser]" value="1"
  38. {% if settingForm['security:passport-github:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  39. <label for="bindByUserName-GitHub">
  40. {{ t("security_setting.Treat username matching as identical", "username") }}
  41. </label>
  42. <p class="help-block">
  43. <small>
  44. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  45. </small>
  46. </p>
  47. </div>
  48. </div>
  49. </div>
  50. </fieldset>
  51. <div class="form-group" id="btn-update">
  52. <div class="col-xs-offset-3 col-xs-6">
  53. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  54. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  55. </div>
  56. </div>
  57. </form>
  58. {# Help Section #}
  59. <hr>
  60. <h4>
  61. <i class="fa fa-question-circle" aria-hidden="true"></i>
  62. <a href="#collapseHelpForGithubOauth" data-toggle="collapse">How to configure GitHub OAuth?</a>
  63. </h4>
  64. <ol id="collapseHelpForGithubOauth" class="collapse">
  65. <li>{{ t("security_setting.OAuth.GitHub.register_1", "https://github.com/settings/developers", "GitHub Developer Settings") }}</li>
  66. <li>{{ t("security_setting.OAuth.GitHub.register_2", "https://${growi.host}/passport/github/callback", "${growi.host}") }}</li>
  67. <li>{{ t("security_setting.OAuth.GitHub.register_3") }}</li>
  68. </ol>
  69. <script>
  70. $('input[name="settingForm[security:passport-github:isEnabled]"]').change(function() {
  71. const isEnabled = ($(this).val() === "true");
  72. if (isEnabled) {
  73. $('#passport-github-hide-when-disabled').show(400);
  74. }
  75. else {
  76. $('#passport-github-hide-when-disabled').hide(400);
  77. }
  78. });
  79. </script>