google-oauth.html 6.6 KB

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