Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
[![Licensed under the MIT License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/lbuchs/WebAuthn/blob/master/LICENSE)
2
[![Requires PHP 7.1.0](https://img.shields.io/badge/PHP-7.1.0-green.svg)](https://php.net)
3
[![Last Commit](https://img.shields.io/github/last-commit/lbuchs/WebAuthn.svg)](https://github.com/lbuchs/WebAuthn/commits/master)
4
 
5
# WebAuthn
6
*A simple PHP WebAuthn (FIDO2) server library*
7
 
8
Goal of this project is to provide a small, lightweight, understandable library to protect logins with passkeys, security keys like Yubico or Solo, fingerprint on Android or Windows Hello.
9
 
10
## Manual
11
See /_test for a simple usage of this library. Check [webauthn.lubu.ch](https://webauthn.lubu.ch) for a working example.
12
 
13
### Supported attestation statement formats
14
* android-key ✅
15
* android-safetynet ✅
16
* apple ✅
17
* fido-u2f ✅
18
* none ✅
19
* packed ✅
20
* tpm ✅
21
 
1441 ariadna 22
> [!NOTE]
23
> This library supports authenticators which are signed with a X.509 certificate or which are self attested. ECDAA is not supported.
1 efrain 24
 
25
## Workflow
26
 
27
             JAVASCRIPT            |          SERVER
28
    ------------------------------------------------------------
29
                             REGISTRATION
30
 
31
 
32
       window.fetch  ----------------->     getCreateArgs
33
                                                 |
34
    navigator.credentials.create   <-------------'
35
            |
36
            '------------------------->     processCreate
37
                                                 |
38
          alert ok or fail      <----------------'
39
 
40
 
41
    ------------------------------------------------------------
42
                          VALIDATION
43
 
44
 
45
       window.fetch ------------------>      getGetArgs
46
                                                 |
47
    navigator.credentials.get   <----------------'
48
            |
49
            '------------------------->      processGet
50
                                                 |
51
          alert ok or fail      <----------------'
52
 
53
## Attestation
54
Typically, when someone logs in, you only need to confirm that they are using the same device they used during
55
registration. In this scenario, you do not require any form of attestation.
56
However, if you need additional security, such as when your company mandates the use of a Solokey for login,
57
you can verify its authenticity through direct attestation. Companies may also purchase authenticators that
58
are signed with their own root certificate, enabling them to validate that an authenticator is affiliated with
59
their organization.
60
 
61
### no attestation
62
just verify that the device is the same device used on registration.
63
You can use 'none' attestation with this library if you only check 'none' as format.
64
 
1441 ariadna 65
> [!TIP]
66
> this is propably what you want to use if you want secure login for a public website.
67
 
1 efrain 68
### indirect attestation
69
the browser may replace the AAGUID and attestation statement with a more privacy-friendly and/or more easily
70
verifiable version of the same data (for example, by employing an anonymization CA).
71
You can not validate against any root ca, if the browser uses a anonymization certificate.
72
this library sets attestation to indirect, if you select multiple formats but don't provide any root ca.
73
 
1441 ariadna 74
> [!TIP]
75
> hybrid soultion, clients may be discouraged by browser warnings but then you know what device they're using (statistics rulez!)
76
 
1 efrain 77
### direct attestation
78
the browser proviedes data about the identificator device, the device can be identified uniquely. User could be tracked over multiple sites, because of that the browser may show a warning message about providing this data when register.
79
this library sets attestation to direct, if you select multiple formats and provide root ca's.
80
 
1441 ariadna 81
> [!TIP]
82
> this is probably what you want if you know what devices your clients are using and make sure that only this devices are used.
83
 
84
## Passkeys / Client-side discoverable Credentials
1 efrain 85
A Client-side discoverable Credential Source is a public key credential source whose credential private key is stored in the authenticator,
86
client or client device. Such client-side storage requires a resident credential capable authenticator.
87
This is only supported by FIDO2 hardware, not by older U2F hardware.
88
 
1441 ariadna 89
>[!NOTE]
90
>Passkeys is a technique that allows sharing credentials stored on the device with other devices. So from a technical standpoint of the server, there is no difference to client-side discoverable credentials. The difference is only that the phone or computer system is automatically syncing the credentials between the user’s devices via a cloud service. The cross-device sync of passkeys is managed transparently by the OS.
91
 
1 efrain 92
### How does it work?
1441 ariadna 93
In a typical server-side key management process, a user initiates a request by entering their username and, in some cases, their password.
94
The server validates the user's credentials and, upon successful authentication, retrieves a list of all public key identifiers associated with that user account.
95
This list is then returned to the authenticator, which selects the first credential identifier it issued and responds with a signature that can be verified using the public key registered during the registration process.
1 efrain 96
 
97
In a client-side key process, the user does not need to provide a username or password.
1441 ariadna 98
Instead, the authenticator searches its own memory to see if it has saved a key for the relying party (domain).
1 efrain 99
If a key is found, the authentication process proceeds in the same way as it would if the server had sent a list
100
of identifiers. There is no difference in the verification process.
101
 
102
### How can I use it with this library?
103
#### on registration
104
When calling `WebAuthn\WebAuthn->getCreateArgs`, set `$requireResidentKey` to true,
105
to notify the authenticator that he should save the registration in its memory.
106
 
107
#### on login
108
When calling `WebAuthn\WebAuthn->getGetArgs`, don't provide any `$credentialIds` (the authenticator will look up the ids in its own memory and returns the user ID as userHandle).
1441 ariadna 109
Set the type of authenticator to `hybrid` (Passkey scanned via QR Code) and `internal` (Passkey stored on the device itself).
1 efrain 110
 
111
#### disadvantage
112
The RP ID (= domain) is saved on the authenticator. So If an authenticator is lost, its theoretically possible to find the services, which the authenticator is used and login there.
113
 
1441 ariadna 114
### device support
1 efrain 115
Availability of built-in passkeys that automatically synchronize to all of a user’s devices: (see also [passkeys.dev/device-support](https://passkeys.dev/device-support/))
1441 ariadna 116
* Apple iOS 16+ / iPadOS 16+ / macOS Ventura+
117
* Android 9+
118
* Microsoft Windows 11 23H2+
1 efrain 119
 
120
## Requirements
121
* PHP >= 8.0 with [OpenSSL](http://php.net/manual/en/book.openssl.php) and [Multibyte String](https://www.php.net/manual/en/book.mbstring.php)
122
* Browser with [WebAuthn support](https://caniuse.com/webauthn) (Firefox 60+, Chrome 67+, Edge 18+, Safari 13+)
123
* PHP [Sodium](https://www.php.net/manual/en/book.sodium.php) (or [Sodium Compat](https://github.com/paragonie/sodium_compat) ) for [Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) support
124
 
125
## Infos about WebAuthn
126
* [Wikipedia](https://en.wikipedia.org/wiki/WebAuthn)
127
* [W3C](https://www.w3.org/TR/webauthn/)
128
* [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API)
129
* [dev.yubico](https://developers.yubico.com/FIDO2/)
130
* [FIDO Alliance](https://fidoalliance.org)
131
* [passkeys](https://passkeys.dev/)
132
 
133
## FIDO2 Hardware
134
* [Yubico](https://www.yubico.com)
135
* [Solo](https://solokeys.com) Open Source!
136
* [Nitrokey](https://www.nitrokey.com/)
137
* [Feitan](https://fido.ftsafe.com/)
138
* [TrustKey](https://www.trustkeysolutions.com)
139
* [Google Titan](https://cloud.google.com/titan-security-key)
140
* [Egis](https://www.egistec.com/u2f-solution/)
141
* [OneSpan](https://www.vasco.com/products/two-factor-authenticators/hardware/one-button/digipass-secureclick.html)
142
* [Hypersecu](https://hypersecu.com/tmp/products/hyperfido)
143
* [Kensington VeriMarkâ„¢](https://www.kensington.com/)
144
* [Token2](https://www.token2.com/shop/category/fido2-keys)