An open API service indexing awesome lists of open source software.

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.

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