Finished Conditional UI
This commit is contained in:
@@ -2,16 +2,19 @@
|
||||
<script type="application/javascript" src="{% static 'mfa/js/cbor.js' %}"></script>
|
||||
<script type="application/javascript" src="{% static 'mfa/js/ua-parser.min.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
function authen()
|
||||
function authen()
|
||||
{
|
||||
fetch('{% url 'fido2_begin_auth' %}', {
|
||||
method: 'GET',
|
||||
}).then(function(response) {
|
||||
if(response.ok) return response.arrayBuffer();
|
||||
throw new Error('No credential available to authenticate!');
|
||||
}).then(CBOR.decode).then(function(options) {
|
||||
}).then(CBOR.decode).then(async function(options) {
|
||||
console.log(options)
|
||||
return navigator.credentials.get(options);
|
||||
{% if conditionalUI %}
|
||||
options["mediation"] = 'conditional';
|
||||
{% endif %}
|
||||
return navigator.credentials.get(options);
|
||||
}).then(function(assertion) {
|
||||
res=CBOR.encode({
|
||||
"credentialId": new Uint8Array(assertion.rawId),
|
||||
|
||||
15
mfa/templates/FIDO2/FormFill.html
Normal file
15
mfa/templates/FIDO2/FormFill.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<script type="application/javascript">
|
||||
$(document).ready(async function () {
|
||||
if (window.PublicKeyCredential &&
|
||||
PublicKeyCredential.isConditionalMediationAvailable
|
||||
)
|
||||
{
|
||||
// Check if conditional mediation is available.
|
||||
const isCMA = await PublicKeyCredential.isConditionalMediationAvailable()
|
||||
if (isCMA) {
|
||||
authen();
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% include 'FIDO2/Auth_JS.html' with conditionalUI=True %}
|
||||
Reference in New Issue
Block a user