https://github.com/markstory/cakephp-webauthn-example
An example application using U2F authentication (Passkeys)
https://github.com/markstory/cakephp-webauthn-example
Last synced: about 2 months ago
JSON representation
An example application using U2F authentication (Passkeys)
- Host: GitHub
- URL: https://github.com/markstory/cakephp-webauthn-example
- Owner: markstory
- Created: 2023-05-24T02:47:08.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-05T14:06:51.000Z (almost 2 years ago)
- Last Synced: 2025-04-11T01:53:18.652Z (about 2 months ago)
- Language: PHP
- Size: 412 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CakePHP Webauthn Example Application

[](https://packagist.org/packages/cakephp/app)
[](https://github.com/phpstan/phpstan)An example application for using Webauthn and soon Passkeys with CakePHP
and the CakePHP authentication plugin. If this proves useful, it could become
a plugin.## Installation
1. Download [Composer](https://getcomposer.org/doc/00-intro.md) or update `composer self-update`.
2. Run `php composer.phar create-project --prefer-dist cakephp/app [app_name]`.If Composer is installed globally, run
```bash
composer create-project --prefer-dist markstory/cakephp-webauthn-example
```In case you want to use a custom app dir name (e.g. `/cake-webauth/`):
```bash
composer create-project --prefer-dist markstory/cakephp-webauthn-example cake-webauth
```## Running the Application
:warning: Webauthn **requires** HTTPS. If you run this example on an HTTP only port it will not work.
If you have a SSL server running you can have it proxy the CakePHP dev server,
or serve the application directly.```bash
bin/cake server -p 8765
```### mkcert & stunnel
Using a pair of CLI utilities you can generate an HTTPs proxy for the cakephp
dev server. I found this pretty simple to use on linux.Generate certificates for your local machine using `mkcert`
```bash
mkcert localhost
cat localhost.pem localhost-key.pem > localhost-bundle.pem
chmod 0666 *.pem
```This will generate certificate & key file. Create the bundled certificate
for `stunnel`Then in one terminal, run: `bin/cake server` and then in another run
```bash
sudo stunnel3 -f -d 443 -r 8765 -p ./localhost-bundle.pem
```Lastly you can use hosted services to create SSL tunnels.
## Configuration
Read and edit the environment specific `config/app_local.php` and set up the
`'Datasources'` and any other configuration relevant for your application.
Other environment agnostic settings can be changed in `config/app.php`.## What's included
A sample application that:
* A CakePHP Authentication plugin compatible Authenticator and high-level API
for building passkey based flows.
* Allows new users to be created using U2F authenticators (also referred to as
Passkeys)
* Allows users to login with their U2F device.
* Allows a user to register multiple devices.Still to be built:
- Preventing duplicates passkeys to be added by the same device.
- Preventing deletion of a user's last passkey.