google-oauth.html 5.5 KB

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