google-oauth.html 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 class="alert-anchor">{{ t("security_setting.OAuth.Google.name") }}{{ t("security_setting.configuration") }}</legend>
  4. {% set nameForIsGoogleEnabled = "settingForm[security:passport-google:isEnabled]" %}
  5. {% set isGoogleEnabled = settingForm['security:passport-google:isEnabled'] %}
  6. <div class="form-group">
  7. <label for="{{nameForIsGoogleEnabled}}" class="col-xs-3 control-label">{{ t("security_setting.OAuth.Google.name") }}</label>
  8. <div class="col-xs-6">
  9. <div class="btn-group btn-toggle" data-toggle="buttons">
  10. <label class="btn btn-default btn-rounded btn-outline {% if isGoogleEnabled %}active{% endif %}" data-active-class="primary">
  11. <input name="{{nameForIsGoogleEnabled}}" value="true" type="radio"
  12. {% if true === isGoogleEnabled %}checked{% endif %}> ON
  13. </label>
  14. <label class="btn btn-default btn-rounded btn-outline {% if !isGoogleEnabled %}active{% endif %}" data-active-class="default">
  15. <input name="{{nameForIsGoogleEnabled}}" value="false" type="radio"
  16. {% if !isGoogleEnabled %}checked{% endif %}> OFF
  17. </label>
  18. </div>
  19. </div>
  20. </div>
  21. <fieldset id="passport-google-hide-when-disabled" {%if !isGoogleEnabled %}style="display: none;"{% endif %}>
  22. <div class="form-group">
  23. <label for="settingForm[security:passport-google:clientId]" class="col-xs-3 control-label">{{ t("security_setting.clientID") }}</label>
  24. <div class="col-xs-6">
  25. <input class="form-control" type="text" name="settingForm[security:passport-google:clientId]" value="{{ settingForm['security:passport-google:clientId'] || '' }}">
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label for="settingForm[security:passport-google:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  30. <div class="col-xs-6">
  31. <input class="form-control" type="text" name="settingForm[security:passport-google:clientSecret]" value="{{ settingForm['security:passport-google:clientSecret'] || '' }}">
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <div class="col-xs-6 col-xs-offset-3">
  36. <div class="checkbox checkbox-info">
  37. <input type="checkbox" id="bindByUserName-Google" name="settingForm[security:passport-google:isSameUsernameTreatedAsIdenticalUser]" value="1"
  38. {% if settingForm['security:passport-google:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  39. <label for="bindByUserName-Google">
  40. {{ t("security_setting.Treat username matching as identical", "username") }}
  41. </label>
  42. <p class="help-block">
  43. <small>
  44. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  45. </small>
  46. </p>
  47. </div>
  48. </div>
  49. </div>
  50. </fieldset>
  51. <div class="form-group" id="btn-update">
  52. <div class="col-xs-offset-3 col-xs-6">
  53. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  54. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  55. </div>
  56. </div>
  57. </form>
  58. {# Help Section #}
  59. <hr>
  60. <h4>
  61. <i class="fa fa-question-circle" aria-hidden="true"></i>
  62. <a href="#collapseHelpForGoogleOauth" data-toggle="collapse">How to configure Google OAuth?</a>
  63. </h4>
  64. <ol id="collapseHelpForGoogleOauth" class="collapse">
  65. <li>{{ t("security_setting.OAuth.Google.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  66. <li>{{ t("security_setting.OAuth.Google.register_2") }}</li>
  67. <li>{{ t("security_setting.OAuth.Google.register_3") }}</li>
  68. <li>{{ t("security_setting.OAuth.Google.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  69. <li>{{ t("security_setting.OAuth.Google.register_5") }}</li>
  70. </ol>
  71. <script>
  72. $('input[name="settingForm[security:passport-google:isEnabled]"]').change(function() {
  73. const isEnabled = ($(this).val() === "true");
  74. if (isEnabled) {
  75. $('#passport-google-hide-when-disabled').show(400);
  76. }
  77. else {
  78. $('#passport-google-hide-when-disabled').hide(400);
  79. }
  80. });
  81. </script>