github.html 4.5 KB

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