google-oauth.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. <p class="help-block">
  27. <small>
  28. {{ t("security_setting.Use env var if empty", "OAUTH_GOOGLE_CLIENT_ID") }}
  29. </small>
  30. </p>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label for="settingForm[security:passport-google:clientSecret]" class="col-xs-3 control-label">{{ t("security_setting.client_secret") }}</label>
  35. <div class="col-xs-6">
  36. <input class="form-control" type="text" name="settingForm[security:passport-google:clientSecret]" value="{{ settingForm['security:passport-google:clientSecret'] || '' }}">
  37. <p class="help-block">
  38. <small>
  39. {{ t("security_setting.Use env var if empty", "OAUTH_GOOGLE_CLIENT_SECRET") }}
  40. </small>
  41. </p>
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label for="settingForm[security:passport-google:callbackUrl]" class="col-xs-3 control-label">{{ t("security_setting.callback_URL") }}</label>
  46. <div class="col-xs-6">
  47. <input class="form-control" type="text" name="settingForm[security:passport-google:callbackUrl]" value="{{ settingForm['security:passport-google:callbackUrl'] || '' }}"
  48. placeholder="http(s)://${growi.host}/passport/google/callback">
  49. <p class="help-block">
  50. Input <code>http(s)://${growi.host}/passport/google/callback</code><br>
  51. <small>
  52. {{ t("security_setting.Use env var if empty", "OAUTH_GOOGLE_CALLBACK_URI") }}
  53. </small>
  54. </p>
  55. </div>
  56. </div>
  57. <div class="form-group">
  58. <div class="col-xs-6 col-xs-offset-3">
  59. <div class="checkbox checkbox-info">
  60. <input type="checkbox" id="bindByUserName-Google" name="settingForm[security:passport-google:isSameUsernameTreatedAsIdenticalUser]" value="1"
  61. {% if settingForm['security:passport-google:isSameUsernameTreatedAsIdenticalUser'] %}checked{% endif %} />
  62. <label for="bindByUserName-Google">
  63. {{ t("security_setting.Treat username matching as identical", "username") }}
  64. </label>
  65. <p class="help-block">
  66. <small>
  67. {{ t("security_setting.Treat username matching as identical_warn", "username") }}
  68. </small>
  69. </p>
  70. </div>
  71. </div>
  72. </div>
  73. </fieldset>
  74. <div class="form-group" id="btn-update">
  75. <div class="col-xs-offset-3 col-xs-6">
  76. <input type="hidden" name="_csrf" value="{{ csrf() }}">
  77. <button type="submit" class="btn btn-primary">{{ t('Update') }}</button>
  78. </div>
  79. </div>
  80. </form>
  81. {# Help Section #}
  82. <hr>
  83. <h4>
  84. <i class="fa fa-question-circle" aria-hidden="true"></i>
  85. <a href="#collapseHelpForGoogleOauth" data-toggle="collapse">How to configure Google OAuth?</a>
  86. </h4>
  87. <ol id="collapseHelpForGoogleOauth" class="collapse">
  88. <li>{{ t("security_setting.OAuth.Google.register_1", "https://console.cloud.google.com/apis/credentials", "Google Cloud Platform API Manager") }}</li>
  89. <li>{{ t("security_setting.OAuth.Google.register_2") }}</li>
  90. <li>{{ t("security_setting.OAuth.Google.register_3") }}</li>
  91. <li>{{ t("security_setting.OAuth.Google.register_4", "https://${growi.host}/passport/google/callback", "${growi.host}") }}</li>
  92. <li>{{ t("security_setting.OAuth.Google.register_5") }}</li>
  93. </ol>
  94. <script>
  95. $('input[name="settingForm[security:passport-google:isEnabled]"]').change(function() {
  96. const isEnabled = ($(this).val() === "true");
  97. if (isEnabled) {
  98. $('#passport-google-hide-when-disabled').show(400);
  99. }
  100. else {
  101. $('#passport-google-hide-when-disabled').hide(400);
  102. }
  103. });
  104. </script>