google-oauth.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <form action="/_api/admin/security/passport-google" method="post" class="form-horizontal passportStrategy" id="googleSetting" role="form"
  2. {% if isRestartingServerNeeded %}style="opacity: 0.4;"{% endif %}>
  3. <legend>Google OAuth {{ t("security_setting.configuration") }}</legend>
  4. <p class="well alert-anchor">{{ t("security_setting.connect_api_manager") }}</p>
  5. {% set nameForIsGoogleEnabled = "settingForm[security:passport-google:isEnabled]" %}
  6. {% set isGoogleEnabled = settingForm['security:passport-google:isEnabled'] %}
  7. <div class="form-group">
  8. <label for="{{nameForIsGoogleEnabled}}" class="col-xs-3 control-label">Use Google 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 isGoogleEnabled %}active{% endif %}" data-active-class="primary">
  12. <input name="{{nameForIsGoogleEnabled}}" value="true" type="radio"
  13. {% if true === isGoogleEnabled %}checked{% endif %}> ON
  14. </label>
  15. <label class="btn btn-default btn-rounded btn-outline {% if !isGoogleEnabled %}active{% endif %}" data-active-class="default">
  16. <input name="{{nameForIsGoogleEnabled}}" value="false" type="radio"
  17. {% if !isGoogleEnabled %}checked{% endif %}> OFF
  18. </label>
  19. </div>
  20. </div>
  21. </div>
  22. <fieldset id="passport-google-hide-when-disabled" {%if !isGoogleEnabled %}style="display: none;"{% endif %}>
  23. <h4>{{ t("security_setting.google_setting") }}</h4>
  24. <ol class="help-block">
  25. <li>{{ t("security_setting.access_api_manager") }}</li>
  26. <li>{{ t("security_setting.create_project") }}</li>
  27. <li>{{ t("security_setting.create_auth_to_oauth") }}</li>
  28. <ol>
  29. <li>{{ t("security_setting.select_webapp") }}</li>
  30. <li>{{ t("security_setting.change_redirect_url") }}</li>
  31. </ol>
  32. </ol>
  33. <div class="form-group">
  34. <label for="settingForm[security:passport-google: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-google:clientId]" value="{{ settingForm['security:passport-google:clientId'] || '' }}">
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label for="settingForm[security:passport-google: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-google:clientSecret]" value="{{ settingForm['security:passport-google: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-Google" name="settingForm[security:passport-google:isSameUsernameTreatedAsIdenticalUser]" value="1"
  49. {% if settingForm['security:passport-google:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  50. <label for="bindByUserName-Google">
  51. {{ t("security_setting.ldap.Treat username matching as identical") }}
  52. </label>
  53. <p class="help-block">
  54. <small>
  55. {{ t("security_setting.ldap.Treat username matching as identical_warn") }}
  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. <button type="button"
  67. class="btn btn-default passport-google-hide-when-disabled"
  68. data-target="#test-google-account" data-toggle="modal"
  69. {%if !isGoogleEnabled %}style="display: none;"{% endif %}>
  70. {{ t("security_setting.ldap.test_config") }}
  71. </button>
  72. </div>
  73. </div>
  74. </form>
  75. {% if false %}
  76. <hr>
  77. <h4>
  78. <i class="fa fa-question-circle" aria-hidden="true"></i>
  79. <a href="#collapseHelpForApp" data-toggle="collapse">How to configure Slack App?</a>
  80. </h4>
  81. <ol id="collapseHelpForApp" class="collapse">
  82. <li>
  83. Register Slack App
  84. <ol>
  85. <li>
  86. Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
  87. <dl class="dl-horizontal">
  88. <dt>App Name</dt> <dd><code>growi</code> </dd>
  89. <dt>Development Slack Team</dt> <dd>Select the team you want to notify to.</dd>
  90. </dl>
  91. </li>
  92. <li><strong>Save</strong> it.</li>
  93. </ol>
  94. </li>
  95. <li>
  96. Get App Credentials
  97. <ol>
  98. <li>Go To "Basic Information" page and make a note "Client ID" and "Client Secret".</li>
  99. </ol>
  100. </li>
  101. <li>
  102. Set Redirect URLs
  103. <ol>
  104. <li>Go to "OAuth &amp; Permissions" page.</li>
  105. <li>Add <code><script>document.write(location.origin);</script>/admin/notification/slackAuth</code> .</li>
  106. <li>Don't forget to <strong>save</strong>.</li>
  107. </ol>
  108. </li>
  109. <li>
  110. Set Permission Scopes to the App
  111. <ol>
  112. <li>Go to "OAuth &amp; Permissions" page.</li>
  113. <li>Add "Send messages as GROWI"(<code>chat:write:bot</code>).</li>
  114. <li>Don't forget to <strong>save</strong>.</li>
  115. </ol>
  116. </li>
  117. <li>
  118. Create a bot user
  119. <ol>
  120. <li>Go to "Bot Users" page and add.</li>
  121. </ol>
  122. </li>
  123. <li>
  124. Install the app
  125. <ol>
  126. <li>Go to "Install App to Your Team" page and install.</li>
  127. </ol>
  128. </li>
  129. <li>
  130. (At Team) Approve the app
  131. <ol>
  132. <li>Go to the management Apps page for the team you installed the app and approve "growi".</li>
  133. </ol>
  134. </li>
  135. <li>
  136. (At Team) Invite the bot to your team
  137. <ol>
  138. <li>Invite the user you created in <code>4. Add a bot user</code> to the channel you notify to.</li>
  139. </ol>
  140. </li>
  141. <li>
  142. (At GROWI admin page) Input "clientId" and "clientSecret" and submit on this page.
  143. </li>
  144. <li>
  145. (At GROWI admin page) Click "Connect to Slack" button to start OAuth process.
  146. </li>
  147. </ol>
  148. {% endif %}
  149. <div class="modal test-google-account" id="test-google-account">
  150. <div class="modal-dialog">
  151. <div class="modal-content">
  152. <div class="modal-header">
  153. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  154. <div class="modal-title">Test Google Account</div>
  155. </div>
  156. <div class="modal-body">
  157. {% include '../../../widget/passport/ldap-association-tester.html' with { showLog: true } %}
  158. </div><!-- /.modal-body -->
  159. </div><!-- /.modal-content -->
  160. </div><!-- /.modal-dialog -->
  161. </div><!-- /.modal -->
  162. <script>
  163. $('input[name="settingForm[security:passport-google:isEnabled]"]').change(function() {
  164. const isEnabled = ($(this).val() === "true");
  165. if (isEnabled) {
  166. $('#passport-google-hide-when-disabled').show(400);
  167. }
  168. else {
  169. $('#passport-google-hide-when-disabled').hide(400);
  170. }
  171. });
  172. </script>