totp.ftl 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <#import "template.ftl" as layout>
  2. <@layout.mainLayout active='totp' bodyClass='totp'; section>
  3. <div class="row">
  4. <div class="col-md-10">
  5. <h2>${msg("authenticatorTitle")}</h2>
  6. </div>
  7. <#if totp.otpCredentials?size == 0>
  8. <div class="col-md-2 subtitle">
  9. <span class="subtitle"><span class="required">*</span> ${msg("requiredFields")}</span>
  10. </div>
  11. </#if>
  12. </div>
  13. <#if totp.enabled>
  14. <table class="table table-bordered table-striped">
  15. <thead>
  16. <#if totp.otpCredentials?size gt 1>
  17. <tr>
  18. <th colspan="4">${msg("configureAuthenticators")}</th>
  19. </tr>
  20. <#else>
  21. <tr>
  22. <th colspan="3">${msg("configureAuthenticators")}</th>
  23. </tr>
  24. </#if>
  25. </thead>
  26. <tbody>
  27. <#list totp.otpCredentials as credential>
  28. <tr>
  29. <td class="provider">${msg("mobile")}</td>
  30. <#if totp.otpCredentials?size gt 1>
  31. <td class="provider">${credential.id}</td>
  32. </#if>
  33. <td class="provider">${credential.userLabel!}</td>
  34. <td class="action">
  35. <form action="${url.totpUrl}" method="post" class="form-inline">
  36. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  37. <input type="hidden" id="submitAction" name="submitAction" value="Delete">
  38. <input type="hidden" id="credentialId" name="credentialId" value="${credential.id}">
  39. <button id="remove-mobile" class="btn btn-default">
  40. <i class="pficon pficon-delete"></i>
  41. </button>
  42. </form>
  43. </td>
  44. </tr>
  45. </#list>
  46. </tbody>
  47. </table>
  48. <#else>
  49. <hr/>
  50. <ol>
  51. <li>
  52. <p>${msg("totpStep1")}</p>
  53. <ul>
  54. <#list totp.policy.supportedApplications as app>
  55. <li>${app}</li>
  56. </#list>
  57. </ul>
  58. </li>
  59. <#if mode?? && mode = "manual">
  60. <li>
  61. <p>${msg("totpManualStep2")}</p>
  62. <p><span id="kc-totp-secret-key">${totp.totpSecretEncoded}</span></p>
  63. <p><a href="${totp.qrUrl}" id="mode-barcode">${msg("totpScanBarcode")}</a></p>
  64. </li>
  65. <li>
  66. <p>${msg("totpManualStep3")}</p>
  67. <ul>
  68. <li id="kc-totp-type">${msg("totpType")}: ${msg("totp." + totp.policy.type)}</li>
  69. <li id="kc-totp-algorithm">${msg("totpAlgorithm")}: ${totp.policy.getAlgorithmKey()}</li>
  70. <li id="kc-totp-digits">${msg("totpDigits")}: ${totp.policy.digits}</li>
  71. <#if totp.policy.type = "totp">
  72. <li id="kc-totp-period">${msg("totpInterval")}: ${totp.policy.period}</li>
  73. <#elseif totp.policy.type = "hotp">
  74. <li id="kc-totp-counter">${msg("totpCounter")}: ${totp.policy.initialCounter}</li>
  75. </#if>
  76. </ul>
  77. </li>
  78. <#else>
  79. <li>
  80. <p>${msg("totpStep2")}</p>
  81. <p><img src="data:image/png;base64, ${totp.totpSecretQrCode}" alt="Figure: Barcode"></p>
  82. <p><a href="${totp.manualUrl}" id="mode-manual">${msg("totpUnableToScan")}</a></p>
  83. </li>
  84. </#if>
  85. <li>
  86. <p>${msg("totpStep3")}</p>
  87. <p>${msg("totpStep3DeviceName")}</p>
  88. </li>
  89. </ol>
  90. <hr/>
  91. <form action="${url.totpUrl}" class="form-horizontal" method="post">
  92. <input type="hidden" id="stateChecker" name="stateChecker" value="${stateChecker}">
  93. <div class="form-group">
  94. <div class="col-sm-2 col-md-2">
  95. <label for="totp" class="control-label">${msg("authenticatorCode")}</label> <span class="required">*</span>
  96. </div>
  97. <div class="col-sm-10 col-md-10">
  98. <input type="text" class="form-control" id="totp" name="totp" autocomplete="off" autofocus>
  99. <input type="hidden" id="totpSecret" name="totpSecret" value="${totp.totpSecret}"/>
  100. </div>
  101. </div>
  102. <div class="form-group" ${messagesPerField.printIfExists('userLabel',properties.kcFormGroupErrorClass!)}">
  103. <div class="col-sm-2 col-md-2">
  104. <label for="userLabel" class="control-label">${msg("totpDeviceName")}</label> <#if totp.otpCredentials?size gte 1><span class="required">*</span></#if>
  105. </div>
  106. <div class="col-sm-10 col-md-10">
  107. <input type="text" class="form-control" id="userLabel" name="userLabel" autocomplete="off">
  108. </div>
  109. </div>
  110. <div class="form-group">
  111. <div id="kc-form-buttons" class="col-md-offset-2 col-md-10 submit">
  112. <div class="">
  113. <button type="submit"
  114. class="${properties.kcButtonClass!} ${properties.kcButtonPrimaryClass!} ${properties.kcButtonLargeClass!}"
  115. id="saveTOTPBtn" name="submitAction" value="Save">${msg("doSave")}
  116. </button>
  117. <button type="submit"
  118. class="${properties.kcButtonClass!} ${properties.kcButtonDefaultClass!} ${properties.kcButtonLargeClass!}"
  119. id="cancelTOTPBtn" name="submitAction" value="Cancel">${msg("doCancel")}
  120. </button>
  121. </div>
  122. </div>
  123. </div>
  124. </form>
  125. </#if>
  126. </@layout.mainLayout>