@@ -197,14 +197,16 @@ def generate_registration(cls, user: User, session: SessionStore) -> str:
197
197
198
198
- `str` JSON string
199
199
"""
200
- existing_credentials = SecurityKey .credentials (user .username ,ignore_credential_filter = True )
200
+ existing_credentials = SecurityKey .credentials (
201
+ user .username , ignore_credential_filter = True
202
+ )
201
203
opts = webauthn .generate_registration_options (
202
204
rp_id = settings .WEBAUTHN_RP_ID ,
203
205
rp_name = settings .WEBAUTHN_RP_NAME ,
204
206
user_id = UserHandle .require_for_user (user ).handle ,
205
207
user_name = user .username ,
206
208
attestation = getattr (settings , "WEBAUTHN_ATTESTATION" , "none" ),
207
- exclude_credentials = existing_credentials
209
+ exclude_credentials = existing_credentials ,
208
210
)
209
211
210
212
cls .set_challenge (session , opts .challenge )
@@ -282,10 +284,12 @@ def verify_registration(
282
284
SecurityKeyDevice .require_for_user (user )
283
285
return key
284
286
285
-
286
287
@classmethod
287
288
def credentials (
288
- cls , username : User | str , for_login : bool = False , ignore_credential_filter = False
289
+ cls ,
290
+ username : User | str ,
291
+ for_login : bool = False ,
292
+ ignore_credential_filter = False ,
289
293
) -> list [PublicKeyCredentialDescriptor ]:
290
294
"""
291
295
Returns a list of credentials for the specified username
@@ -305,8 +309,8 @@ def credentials(
305
309
"""
306
310
307
311
qset = cls .objects .filter (user__username = username )
308
- # ignore credential_filter to get all credentials data
309
- # example: used for excludeCredentials to prevent duplication of keys in 1 account in the same key
312
+ # ignore credential_filter to get all credentials data
313
+ # example: used for excludeCredentials to prevent duplication of keys in 1 account in the same key
310
314
if not ignore_credential_filter :
311
315
# if to be used for passkey login, exclude
312
316
# credentials that are not enabled for that.
@@ -338,12 +342,12 @@ def generate_authentication(
338
342
- `str` JSON
339
343
"""
340
344
options = {
341
- "rp_id" :settings .WEBAUTHN_RP_ID ,
345
+ "rp_id" : settings .WEBAUTHN_RP_ID ,
342
346
}
343
347
if not for_login :
344
- options .update ({
345
- "allow_credentials" :cls .credentials (username , for_login = for_login )
346
- } )
348
+ options .update (
349
+ { "allow_credentials" : cls .credentials (username , for_login = for_login )}
350
+ )
347
351
opts = webauthn .generate_authentication_options (** options )
348
352
cls .set_challenge (session , opts .challenge )
349
353
return webauthn .options_to_json (opts )
0 commit comments