google-oauth.html 6.5 KB

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