Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

store database #34

Open
ivansalieto opened this issue May 10, 2021 · 8 comments
Open

store database #34

ivansalieto opened this issue May 10, 2021 · 8 comments
Labels
question Further information is requested

Comments

@ivansalieto
Copy link

Hi!

I'm trying to save to database and it doesn't work. When I store "credentialId" a value is saved each time, of unknown format. I just want to save to database instead of "_SESSION" ... but is it not possible?

@My1
Copy link
Contributor

My1 commented May 23, 2021

you have some sample code?

I go with something like this:

//do process create with the needed parameters and feed the result object into $data
$data = $WebAuthn->processCreate($clientDataJSON, $attestationObject, $challenge,($uv==="required"));
$data->credentialId=base64_encode($data->credentialId); //base64 encode the cred-ID
$data->AAGUID=bin2uuid($data->AAGUID); //external function to format binary AAGUID into an actual guid format
$data->signatureCounter=($data->signatureCounter === NULL ? 0 : $data->signatureCounter); //check whether the sig counter is actually a value, if not, set zero
//optional: $data->certificate is the cert.

now you have basically 3 or 4 things to throw into the database.

@BrunoFigueiraBarros
Copy link

You can show this function bin2uuid, I'm trying to deploy in my project! tks

@My1
Copy link
Contributor

My1 commented Jan 28, 2022

sure I just got it off of someone online like stackoverlow or whatever, but dunno where exactly.

function bin2uuid($bin) {
    $uuidReadable = unpack("H*",$bin);
    $uuidReadable = preg_replace("/([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})/", "$1-$2-$3-$4-$5", $uuidReadable);
    $uuidReadable = array_merge($uuidReadable)[0];
    return $uuidReadable;
}

@BrunoFigueiraBarros
Copy link

tks for the tip, can you help me to deploy this project on my system?
I have stored all the information on this forum, but I don't know how to display it

@lbuchs lbuchs added the question Further information is requested label Nov 15, 2022
@marcomtz85
Copy link

I'm storing the credentialId as base64 on my database as @My1 kindly showed here, but when I pass that ids to getGetArgs, webauthn fails in the browser side. When I check in the ajax with the "getGetArgs", the ids look empty, something like: "=?BINARY?B?credentialId?=".

Looks like getGetArgs only work when stored in $_SESSION

@My1
Copy link
Contributor

My1 commented Jul 29, 2023

@marcomtz85
When passing the ids back to the function you iirc need to base64 decode them again because the functions run on binary. Also it iirc also needs to be an array

@marcomtz85
Copy link

@My1 y base64_decode them. Is it necessary something else?

@My1
Copy link
Contributor

My1 commented Jul 29, 2023

Make sure it's an array even if there's just one element inside.

So in the end it's an array with binary strings inside. I use array_walk with a pass-by-reference base64 decode wrapper for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants