Skip to content

Commit

Permalink
full name is removed from the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
fumieval committed Sep 19, 2020
1 parent 5cb536b commit b2df4dd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/Web/WebAuthn/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import qualified Data.Text.Read as T
import Crypto.Hash
import Crypto.Hash.Algorithms (SHA256(..))
import qualified Codec.CBOR.Term as CBOR
import qualified Codec.CBOR.Read as CBOR
import qualified Codec.Serialise as CBOR
Expand Down Expand Up @@ -171,19 +170,17 @@ instance J.ToJSON AttestedCredentialData
-- | 5.4.3. User Account Parameters for Credential Generation
data User = User
{ userId :: B.ByteString
, userName :: T.Text
, userDisplayName :: T.Text
} deriving (Generic, Show, Eq)

instance CBOR.Serialise User where
encode (User i n d) = CBOR.encode $ Map.fromList
[("id" :: Text, CBOR.TBytes i), ("name", CBOR.TString n), ("displayName", CBOR.TString d)]
encode (User i d) = CBOR.encode $ Map.fromList
[("id" :: Text, CBOR.TBytes i), ("displayName", CBOR.TString d)]
decode = do
m <- CBOR.decode
CBOR.TBytes i <- maybe (fail "id") pure $ Map.lookup ("id" :: Text) m
CBOR.TString n <- maybe (fail "name") pure $ Map.lookup "name" m
CBOR.TString d <- maybe (fail "displayName") pure $ Map.lookup "displayName" m
return $ User i n d
return $ User i d

data VerificationFailure
= InvalidType
Expand Down
4 changes: 2 additions & 2 deletions wai-middleware-webauthn/demo/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ endpoint: "webauthn"
handler:
fumieval:
- aaguid: "00000000000000000000000000000000"
credentialId: 57QNM7zVr77rN6mN-Z-ZVPnZgh4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
credentialPublicKey: pQECAyYgASFYICmf4vKOR013my0PhZ4IFHU5cAH4uRqnNLtuRLcyZEtUIlggpz_qkbKD1k1C4cNsHPvTCmddL-QG9bSgqs8JOAs3yG8=
credentialId: vcr_XnaBZx6AH3nuDSsmRFS2ZgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==
credentialPublicKey: pQECAyYgASFYIJFR_dt_GWkw5Ldvu2FW9rIjULYzOWpYG_IAmOuqxRbHIlggd8EFrDs8DOrouUYtzqRWPO5Mo84cJf1dWkbhaUmECaM=

timeout: 86400
12 changes: 5 additions & 7 deletions wai-middleware-webauthn/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@
<span class="placeholder">Messages will be displayed here</span>
</div>
<div id="form-register">
<label for="webauthn-full-name">Full name</label>
<input type="text" id="webauthn-full-name">
<br>
<label for="webauthn-display-name">Displayed name</label>
<input type="text" id="webauthn-display-name">
<br>
Expand All @@ -75,17 +72,18 @@
, function(e){
uid = [];
for (var a=[],i=0;i<64;i++){ uid.push(Math.random() * 256) }
let name = document.getElementById("webauthn-display-name").value;
let user = {
id: new Uint8Array(uid),
name: document.getElementById("webauthn-full-name").value,
displayName: document.getElementById("webauthn-display-name").value
displayName: name,
name: name
};
auth.register(user).then(result => {
var div = document.createElement("section");
div.innerHTML = "Add the following pair to config.yaml: <pre><code>"
+ user.displayName + ":"
+ "\n- aaguid: " + result.aaguid
+ "\n credentialId: " + result.credentialId
+ "\n- aaguid: '" + result.aaguid
+ "'\n credentialId: " + result.credentialId
+ "\n credentialPublicKey: " + result.credentialPublicKey
+ "\n</code></pre>";
document.getElementById("webauthn-result").appendChild(div);
Expand Down

0 comments on commit b2df4dd

Please sign in to comment.