github.html 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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>{{ t("security_setting.OAuth.GitHub.name") }}{{ t("security_setting.configuration") }}</legend>
  4. <p class="well alert-anchor">{{ t("security_setting.OAuth.connect_api_manager", "https://github.com/settings/developers", "GitHub Developer Settings") }}</p>
  5. {% set nameForIsGitHubEnabled = "settingForm[security:passport-github:isEnabled]" %}
  6. {% set isGitHubEnabled = settingForm['security:passport-github:isEnabled'] %}
  7. <div class="form-group">
  8. <label for="{{nameForIsGitHubEnabled}}" class="col-xs-3 control-label">{{ t("security_setting.OAuth.GitHub.name") }}</label>
  9. <div class="col-xs-6">
  10. <div class="btn-group btn-toggle" data-toggle="buttons">
  11. <label class="btn btn-default btn-rounded btn-outline {% if isGitHubEnabled %}active{% endif %}" data-active-class="primary">
  12. <input name="{{nameForIsGitHubEnabled}}" value="true" type="radio"
  13. {% if true === isGitHubEnabled %}checked{% endif %}> ON
  14. </label>
  15. <label class="btn btn-default btn-rounded btn-outline {% if !isGitHubEnabled %}active{% endif %}" data-active-class="default">
  16. <input name="{{nameForIsGitHubEnabled}}" value="false" type="radio"
  17. {% if !isGitHubEnabled %}checked{% endif %}> OFF
  18. </label>
  19. </div>
  20. </div>
  21. </div>
  22. <fieldset id="passport-github-hide-when-disabled" {%if !isGitHubEnabled %}style="display: none;"{% endif %}>
  23. <div class="form-group">
  24. <label for="settingForm[security:passport-github:clientId]" class="col-xs-3 control-label">{{ t("security_setting.OAuth.register", t("security_setting.OAuth.GitHub.name") ) }}</label>
  25. <div class="col-xs-6">
  26. <ol class="help-block">
  27. <li>{{ t("security_setting.OAuth.GitHub.register_1", "https://github.com/settings/developers", "GitHub Developer Settings") }}</li>
  28. <li>{{ t("security_setting.OAuth.GitHub.register_2", "https://${growi.host}/passport/github/callback", "${growi.host}") }}</li>
  29. <li>{{ t("security_setting.OAuth.GitHub.register_3") }}</li>
  30. </ol>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label for="settingForm[security:passport-github:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  35. <div class="col-xs-6">
  36. <input class="form-control" type="text" name="settingForm[security:passport-github:clientId]" value="{{ settingForm['security:passport-github:clientId'] || '' }}">
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label for="settingForm[security:passport-github:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  41. <div class="col-xs-6">
  42. <input class="form-control" type="text" name="settingForm[security:passport-github:clientSecret]" value="{{ settingForm['security:passport-github:clientSecret'] || '' }}">
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <div class="col-xs-6 col-xs-offset-3">
  47. <div class="checkbox checkbox-info">
  48. <input type="checkbox" id="bindByUserName-GitHub" name="settingForm[security:passport-github:isSameUsernameTreatedAsIdenticalUser]" value="1"
  49. {% if settingForm['security:passport-github:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  50. <label for="bindByUserName-GitHub">
  51. {{ t("security_setting.Treat username matching as identical", "username") }}
  52. </label>
  53. <p class="help-block">
  54. <small>
  55. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  56. </small>
  57. </p>
  58. </div>
  59. </div>
  60. </div>
  61. </fieldset>
  62. <div class="form-group" id="btn-update">
  63. <div class="col-xs-offset-3 col-xs-6">
  64. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  65. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  66. </div>
  67. </div>
  68. </form>
  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>