https://github.com/jogemu/phpasskey
Concise passkey authentication for php with mysql.
https://github.com/jogemu/phpasskey
mysql passkeys php
Last synced: 4 months ago
JSON representation
Concise passkey authentication for php with mysql.
- Host: GitHub
- URL: https://github.com/jogemu/phpasskey
- Owner: jogemu
- License: 0bsd
- Created: 2024-05-02T12:42:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-10-17T17:56:25.000Z (8 months ago)
- Last Synced: 2025-10-22T01:33:03.723Z (8 months ago)
- Topics: mysql, passkeys, php
- Language: PHP
- Homepage:
- Size: 27.3 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phpasskey
Concise passkey authentication for php with mysql. Only uses cookies once the login process begins.
## Setup
Create the following table.
```sql
CREATE TABLE `passkeys` (
`passkey` varbinary(32) PRIMARY KEY,
`alg` smallint,
`pub` varbinary(294),
`user` int,
`label` varchar(64)
)
```
Add this to the top of any php file that requires login. You can customize the login screen to your liking where the login button is echoed.
```php
connect_error) or exit('mySQLi unable to connect');
$mySQLi->set_charset('utf8mb4');
register_shutdown_function(fn() => $mySQLi->close());
(require 'phpasskey.php')(function() {
// Only continues if not already logged in.
echo 'Login';
}, $mySQLi, register: 'passkey label');
// Only continues if the user is logged in.
echo 'Register';
```
If the above is put in a php file you can require it in other files to reuse a login screen. Passkey registration is only possible if the user is logged in and the passkey label is not omitted. You may login by setting the following session variables.
```php