login-config-totp.ftl 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <#import "template.ftl" as layout>
  2. <@layout.registrationLayout displayRequiredFields=false displayMessage=!messagesPerField.existsError('totp','userLabel'); section>
  3. <#if section = "header">
  4. ${msg("loginTotpTitle")}
  5. <#elseif section = "form">
  6. <ol id="kc-totp-settings">
  7. <li>
  8. <p>${msg("loginTotpStep1")}</p>
  9. <ul id="kc-totp-supported-apps">
  10. <#list totp.policy.supportedApplications as app>
  11. <li>${app}</li>
  12. </#list>
  13. </ul>
  14. </li>
  15. <#if mode?? && mode = "manual">
  16. <li>
  17. <p>${msg("loginTotpManualStep2")}</p>
  18. <p><span id="kc-totp-secret-key">${totp.totpSecretEncoded}</span></p>
  19. <p><a href="${totp.qrUrl}" id="mode-barcode">${msg("loginTotpScanBarcode")}</a></p>
  20. </li>
  21. <li>
  22. <p>${msg("loginTotpManualStep3")}</p>
  23. <p>
  24. <ul>
  25. <li id="kc-totp-type">${msg("loginTotpType")}: ${msg("loginTotp." + totp.policy.type)}</li>
  26. <li id="kc-totp-algorithm">${msg("loginTotpAlgorithm")}: ${totp.policy.getAlgorithmKey()}</li>
  27. <li id="kc-totp-digits">${msg("loginTotpDigits")}: ${totp.policy.digits}</li>
  28. <#if totp.policy.type = "totp">
  29. <li id="kc-totp-period">${msg("loginTotpInterval")}: ${totp.policy.period}</li>
  30. <#elseif totp.policy.type = "hotp">
  31. <li id="kc-totp-counter">${msg("loginTotpCounter")}: ${totp.policy.initialCounter}</li>
  32. </#if>
  33. </ul>
  34. </p>
  35. </li>
  36. <#else>
  37. <li>
  38. <p>${msg("loginTotpStep2")}</p>
  39. <img id="kc-totp-secret-qr-code" src="data:image/png;base64, ${totp.totpSecretQrCode}" alt="Figure: Barcode"><br/>
  40. <p><a href="${totp.manualUrl}" id="mode-manual">${msg("loginTotpUnableToScan")}</a></p>
  41. </li>
  42. </#if>
  43. <li>
  44. <p>${msg("loginTotpStep3")}</p>
  45. <p>${msg("loginTotpStep3DeviceName")}</p>
  46. </li>
  47. </ol>
  48. <form action="${url.loginAction}" class="${properties.kcFormClass!}" id="kc-totp-settings-form" method="post">
  49. <div class="${properties.kcFormGroupClass!}">
  50. <div class="${properties.kcInputWrapperClass!}">
  51. <label for="totp" class="control-label">${msg("authenticatorCode")}</label> <span class="required">*</span>
  52. </div>
  53. <div class="${properties.kcInputWrapperClass!}">
  54. <input type="text" id="totp" name="totp" autocomplete="off" class="${properties.kcInputClass!}"
  55. aria-invalid="<#if messagesPerField.existsError('totp')>true</#if>"
  56. />
  57. <#if messagesPerField.existsError('totp')>
  58. <span id="input-error-otp-code" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
  59. ${kcSanitize(messagesPerField.get('totp'))?no_esc}
  60. </span>
  61. </#if>
  62. </div>
  63. <input type="hidden" id="totpSecret" name="totpSecret" value="${totp.totpSecret}" />
  64. <#if mode??><input type="hidden" id="mode" name="mode" value="${mode}"/></#if>
  65. </div>
  66. <div class="${properties.kcFormGroupClass!}">
  67. <div class="${properties.kcInputWrapperClass!}">
  68. <label for="userLabel" class="control-label">${msg("loginTotpDeviceName")}</label> <#if totp.otpCredentials?size gte 1><span class="required">*</span></#if>
  69. </div>
  70. <div class="${properties.kcInputWrapperClass!}">
  71. <input type="text" class="${properties.kcInputClass!}" id="userLabel" name="userLabel" autocomplete="off"
  72. aria-invalid="<#if messagesPerField.existsError('userLabel')>true</#if>"
  73. />
  74. <#if messagesPerField.existsError('userLabel')>
  75. <span id="input-error-otp-label" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
  76. ${kcSanitize(messagesPerField.get('userLabel'))?no_esc}
  77. </span>
  78. </#if>
  79. </div>
  80. </div>
  81. <#if isAppInitiatedAction??>
  82. <input type="submit"
  83. class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}"
  84. id="saveTOTPBtn" value="${msg("doSubmit")}"
  85. />
  86. <button type="submit"
  87. class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!} ${properties.kcButtonLargeClass!}"
  88. id="cancelTOTPBtn" name="cancel-aia" value="true" />${msg("doCancel")}
  89. </button>
  90. <#else>
  91. <input type="submit"
  92. class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonBlockClass!} ${properties.kcButtonLargeClass!}"
  93. id="saveTOTPBtn" value="${msg("doSubmit")}"
  94. />
  95. </#if>
  96. </form>
  97. </#if>
  98. </@layout.registrationLayout>