google-oauth.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. </fieldset>
  46. <div class="form-group" id="btn-update">
  47. <div class="col-xs-offset-3 col-xs-6">
  48. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  49. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  50. <button type="button"
  51. class="btn btn-default passport-google-hide-when-disabled"
  52. data-target="#test-google-account" data-toggle="modal"
  53. {%if !isGoogleEnabled %}style="display: none;"{% endif %}>
  54. {{ t("security_setting.ldap.test_config") }}
  55. </button>
  56. </div>
  57. </div>
  58. </form>
  59. {% if false %}
  60. <hr>
  61. <h4>
  62. <i class="fa fa-question-circle" aria-hidden="true"></i>
  63. <a href="#collapseHelpForApp" data-toggle="collapse">How to configure Slack App?</a>
  64. </h4>
  65. <ol id="collapseHelpForApp" class="collapse">
  66. <li>
  67. Register Slack App
  68. <ol>
  69. <li>
  70. Create App from <a href="https://api.slack.com/applications/new">this link</a>, and fill the form out as below:
  71. <dl class="dl-horizontal">
  72. <dt>App Name</dt> <dd><code>growi</code> </dd>
  73. <dt>Development Slack Team</dt> <dd>Select the team you want to notify to.</dd>
  74. </dl>
  75. </li>
  76. <li><strong>Save</strong> it.</li>
  77. </ol>
  78. </li>
  79. <li>
  80. Get App Credentials
  81. <ol>
  82. <li>Go To "Basic Information" page and make a note "Client ID" and "Client Secret".</li>
  83. </ol>
  84. </li>
  85. <li>
  86. Set Redirect URLs
  87. <ol>
  88. <li>Go to "OAuth &amp; Permissions" page.</li>
  89. <li>Add <code><script>document.write(location.origin);</script>/admin/notification/slackAuth</code> .</li>
  90. <li>Don't forget to <strong>save</strong>.</li>
  91. </ol>
  92. </li>
  93. <li>
  94. Set Permission Scopes to the App
  95. <ol>
  96. <li>Go to "OAuth &amp; Permissions" page.</li>
  97. <li>Add "Send messages as GROWI"(<code>chat:write:bot</code>).</li>
  98. <li>Don't forget to <strong>save</strong>.</li>
  99. </ol>
  100. </li>
  101. <li>
  102. Create a bot user
  103. <ol>
  104. <li>Go to "Bot Users" page and add.</li>
  105. </ol>
  106. </li>
  107. <li>
  108. Install the app
  109. <ol>
  110. <li>Go to "Install App to Your Team" page and install.</li>
  111. </ol>
  112. </li>
  113. <li>
  114. (At Team) Approve the app
  115. <ol>
  116. <li>Go to the management Apps page for the team you installed the app and approve "growi".</li>
  117. </ol>
  118. </li>
  119. <li>
  120. (At Team) Invite the bot to your team
  121. <ol>
  122. <li>Invite the user you created in <code>4. Add a bot user</code> to the channel you notify to.</li>
  123. </ol>
  124. </li>
  125. <li>
  126. (At GROWI admin page) Input "clientId" and "clientSecret" and submit on this page.
  127. </li>
  128. <li>
  129. (At GROWI admin page) Click "Connect to Slack" button to start OAuth process.
  130. </li>
  131. </ol>
  132. {% endif %}
  133. <div class="modal test-google-account" id="test-google-account">
  134. <div class="modal-dialog">
  135. <div class="modal-content">
  136. <div class="modal-header">
  137. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  138. <div class="modal-title">Test Google Account</div>
  139. </div>
  140. <div class="modal-body">
  141. {% include '../../../widget/passport/ldap-association-tester.html' with { showLog: true } %}
  142. </div><!-- /.modal-body -->
  143. </div><!-- /.modal-content -->
  144. </div><!-- /.modal-dialog -->
  145. </div><!-- /.modal -->
  146. <script>
  147. $('input[name="settingForm[security:passport-google:isEnabled]"]').change(function() {
  148. const isEnabled = ($(this).val() === "true");
  149. if (isEnabled) {
  150. $('#passport-google-hide-when-disabled').show(400);
  151. }
  152. else {
  153. $('#passport-google-hide-when-disabled').hide(400);
  154. }
  155. });
  156. </script>