github.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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>GitHub OAuth {{ t("security_setting.configuration") }}</legend>
  4. <p class="well alert-anchor">{{ t("security_setting.connect_api_manager") }}</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.GitHub_OAuth.use_GitHub_OAuth") }}</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.github_setting") }}</label>
  25. <div class="col-xs-6">
  26. <ol class="help-block">
  27. <li>{{ t("security_setting.access_api_manager") }}</li>
  28. <li>{{ t("security_setting.create_project") }}</li>
  29. <li>{{ t("security_setting.create_auth_to_oauth") }}</li>
  30. <ol>
  31. <li>{{ t("security_setting.select_webapp") }}</li>
  32. <li>{{ t("security_setting.GitHub_OAuth.change_redirect_url", "https://${growi.host}/passport/github/callback", "${growi.host}") }}</li>
  33. </ol>
  34. </ol>
  35. </div>
  36. </div>
  37. <div class="form-group">
  38. <label for="settingForm[security:passport-github:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  39. <div class="col-xs-6">
  40. <input class="form-control" type="text" name="settingForm[security:passport-github:clientId]" value="{{ settingForm['security:passport-github:clientId'] || '' }}">
  41. </div>
  42. </div>
  43. <div class="form-group">
  44. <label for="settingForm[security:passport-github:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  45. <div class="col-xs-6">
  46. <input class="form-control" type="text" name="settingForm[security:passport-github:clientSecret]" value="{{ settingForm['security:passport-github:clientSecret'] || '' }}">
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <div class="col-xs-6 col-xs-offset-3">
  51. <div class="checkbox checkbox-info">
  52. <input type="checkbox" id="bindByUserName-GitHub" name="settingForm[security:passport-github:isSameUsernameTreatedAsIdenticalUser]" value="1"
  53. {% if settingForm['security:passport-github:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  54. <label for="bindByUserName-GitHub">
  55. {{ t("security_setting.ldap.Treat username matching as identical") }}
  56. </label>
  57. <p class="help-block">
  58. <small>
  59. {{ t("security_setting.ldap.Treat username matching as identical_warn") }}
  60. </small>
  61. </p>
  62. </div>
  63. </div>
  64. </div>
  65. </fieldset>
  66. <div class="form-group" id="btn-update">
  67. <div class="col-xs-offset-3 col-xs-6">
  68. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  69. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  70. </div>
  71. </div>
  72. </form>
  73. {% if false %}
  74. <hr>
  75. <h4>
  76. <i class="fa fa-question-circle" aria-hidden="true"></i>
  77. <a href="#collapseHelpForApp" data-toggle="collapse">How to configure Slack App?</a>
  78. </h4>
  79. <ol id="collapseHelpForApp" class="collapse">
  80. <li>
  81. Register Slack App
  82. <ol>
  83. <li>
  84. Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
  85. <dl class="dl-horizontal">
  86. <dt>App Name</dt> <dd><code>growi</code> </dd>
  87. <dt>Development Slack Team</dt> <dd>Select the team you want to notify to.</dd>
  88. </dl>
  89. </li>
  90. <li><strong>Save</strong> it.</li>
  91. </ol>
  92. </li>
  93. <li>
  94. Get App Credentials
  95. <ol>
  96. <li>Go To "Basic Information" page and make a note "Client ID" and "Client Secret".</li>
  97. </ol>
  98. </li>
  99. <li>
  100. Set Redirect URLs
  101. <ol>
  102. <li>Go to "OAuth &amp; Permissions" page.</li>
  103. <li>Add <code><script>document.write(location.origin);</script>/admin/notification/slackAuth</code> .</li>
  104. <li>Don't forget to <strong>save</strong>.</li>
  105. </ol>
  106. </li>
  107. <li>
  108. Set Permission Scopes to the App
  109. <ol>
  110. <li>Go to "OAuth &amp; Permissions" page.</li>
  111. <li>Add "Send messages as GROWI"(<code>chat:write:bot</code>).</li>
  112. <li>Don't forget to <strong>save</strong>.</li>
  113. </ol>
  114. </li>
  115. <li>
  116. Create a bot user
  117. <ol>
  118. <li>Go to "Bot Users" page and add.</li>
  119. </ol>
  120. </li>
  121. <li>
  122. Install the app
  123. <ol>
  124. <li>Go to "Install App to Your Team" page and install.</li>
  125. </ol>
  126. </li>
  127. <li>
  128. (At Team) Approve the app
  129. <ol>
  130. <li>Go to the management Apps page for the team you installed the app and approve "growi".</li>
  131. </ol>
  132. </li>
  133. <li>
  134. (At Team) Invite the bot to your team
  135. <ol>
  136. <li>Invite the user you created in <code>4. Add a bot user</code> to the channel you notify to.</li>
  137. </ol>
  138. </li>
  139. <li>
  140. (At GROWI admin page) Input "clientId" and "clientSecret" and submit on this page.
  141. </li>
  142. <li>
  143. (At GROWI admin page) Click "Connect to Slack" button to start OAuth process.
  144. </li>
  145. </ol>
  146. {% endif %}
  147. <script>
  148. $('input[name="settingForm[security:passport-github:isEnabled]"]').change(function() {
  149. const isEnabled = ($(this).val() === "true");
  150. if (isEnabled) {
  151. $('#passport-github-hide-when-disabled').show(400);
  152. }
  153. else {
  154. $('#passport-github-hide-when-disabled').hide(400);
  155. }
  156. });
  157. </script>