Skip to content

Commit 81ebe77

Browse files
committed
fix: Return the correct Java types when registering passkeys
1 parent d07ae3a commit 81ebe77

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

models/PasskeyService.cfc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ component singleton {
33
property name="clientCredentialRepository" inject="ClientCredentialRepository@cbsecurity-passkeys";
44
property name="log" inject="logbox:logger:{this}";
55

6+
variables.PUBLIC_KEY_TYPE = createObject( "java", "com.yubico.webauthn.data.PublicKeyCredentialType" ).PUBLIC_KEY;
7+
68
function getCredentialIdsForUsername( required string username ) {
79
if ( log.canDebug() ) {
810
log.debug( "Retrieving all credential ids for username [#arguments.username#]." );
911
}
1012

11-
var credentialIds = createObject( "java", "java.util.HashSet" ).init(
12-
variables.clientCredentialRepository.getCredentialIdsForUsername( arguments.username )
13-
);
13+
var credentialIds = variables.clientCredentialRepository.getCredentialIdsForUsername( arguments.username );
1414

1515
if ( log.canDebug() ) {
1616
log.debug(
@@ -19,7 +19,15 @@ component singleton {
1919
);
2020
}
2121

22-
return credentialIds;
22+
return createObject( "java", "java.util.HashSet" ).init(
23+
credentialIds.map( ( credentialId ) => {
24+
return createObject( "java", "com.yubico.webauthn.data.PublicKeyCredentialDescriptor" )
25+
.builder()
26+
.id( toByteArray( credentialId ) )
27+
.type( variables.PUBLIC_KEY_TYPE )
28+
.build();
29+
} )
30+
);;
2331
}
2432

2533
function getUserHandleForUsername( required string username ) {
@@ -139,4 +147,8 @@ component singleton {
139147
);
140148
}
141149

150+
private any function toByteArray( required any value ) {
151+
return createObject( "java", "com.yubico.webauthn.data.ByteArray" ).init( arguments.value );
152+
}
153+
142154
}

0 commit comments

Comments
 (0)