Skip to content

Commit

Permalink
Finish basic development
Browse files Browse the repository at this point in the history
  • Loading branch information
shaokeyibb committed Nov 23, 2023
1 parent 1fe6e2e commit efb198c
Show file tree
Hide file tree
Showing 42 changed files with 3,716 additions and 84 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Flarum Passkey Login

![License](https://img.shields.io/badge/license-Apache-2.0-blue.svg) [![Latest Stable Version](https://img.shields.io/packagist/v/hikarilan/flarum-passkey-login.svg)](https://packagist.org/packages/hikarilan/flarum-passkey-login) [![Total Downloads](https://img.shields.io/packagist/dt/hikarilan/flarum-passkey-login.svg)](https://packagist.org/packages/hikarilan/flarum-passkey-login)
![License](https://img.shields.io/packagist/l/hikarilan/flarum-passkey-login) [![Latest Stable Version](https://img.shields.io/packagist/v/hikarilan/flarum-passkey-login.svg)](https://packagist.org/packages/hikarilan/flarum-passkey-login) [![Total Downloads](https://img.shields.io/packagist/dt/hikarilan/flarum-passkey-login.svg)](https://packagist.org/packages/hikarilan/flarum-passkey-login)

A [Flarum](http://flarum.org) extension. Login to Flarum with Passkey
A [Flarum](http://flarum.org) extension. Login to Flarum with Passkey.

## Installation

Expand All @@ -23,5 +23,4 @@ php flarum cache:clear
## Links

- [Packagist](https://packagist.org/packages/hikarilan/flarum-passkey-login)
- [GitHub](https://github.com/hikarilan/flarum-passkey-login)
- [Discuss](https://discuss.flarum.org/d/PUT_DISCUSS_SLUG_HERE)
- [GitHub](https://github.com/shaokeyibb/flarum-passkey-login)
113 changes: 61 additions & 52 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,64 @@
{
"name": "hikarilan/flarum-passkey-login",
"description": "Login to Flarum with Passkey",
"keywords": [
"flarum"
],
"type": "flarum-extension",
"license": "Apache-2.0",
"require": {
"flarum/core": "^1.2.0"
"name": "hikarilan/flarum-passkey-login",
"description": "Login to Flarum with passkey",
"keywords": [
"flarum",
"passkey",
"webauthn",
"security",
"login"
],
"type": "flarum-extension",
"license": "Apache-2.0",
"require": {
"flarum/core": "^1.2.0",
"web-auth/webauthn-lib": "^4.7"
},
"authors": [
{
"name": "HikariLan",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"source": "https://github.com/shaokeyibb/flarum-passkey-login",
"issues": "https://github.com/shaokeyibb/flarum-passkey-login/issues"
},
"autoload": {
"psr-4": {
"Hikarilan\\FlarumPasskeyLogin\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Passkey Login",
"category": "feature",
"icon": {
"name": "fas fa-key",
"color": "#fff",
"backgroundColor": "#61964e"
}
},
"authors": [
{
"name": "HikariLan",
"email": "[email protected]",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"Hikarilan\\FlarumPasskeyLogin\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Flarum Passkey Login",
"category": "",
"icon": {
"name": "",
"color": "",
"backgroundColor": ""
}
},
"flarum-cli": {
"modules": {
"admin": true,
"forum": true,
"js": true,
"jsCommon": true,
"css": true,
"locale": true,
"gitConf": true,
"githubActions": true,
"prettier": true,
"typescript": true,
"bundlewatch": true,
"backendTesting": false,
"editorConfig": true,
"styleci": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
"flarum-cli": {
"modules": {
"admin": true,
"forum": true,
"js": true,
"jsCommon": true,
"css": true,
"locale": true,
"gitConf": true,
"githubActions": true,
"prettier": true,
"typescript": true,
"bundlewatch": true,
"backendTesting": false,
"editorConfig": true,
"styleci": true
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
65 changes: 60 additions & 5 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,69 @@

namespace Hikarilan\FlarumPasskeyLogin;

use Cose\Algorithm\Manager;
use Cose\Algorithm\Signature\ECDSA\ES256;
use Flarum\Extend;
use Illuminate\Container\Container;
use Webauthn\AttestationStatement\AttestationObjectLoader;
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
use Webauthn\AttestationStatement\NoneAttestationStatementSupport;
use Webauthn\AttestationStatement\PackedAttestationStatementSupport;
use Webauthn\AuthenticationExtensions\ExtensionOutputCheckerHandler;
use Webauthn\AuthenticatorAssertionResponseValidator;
use Webauthn\AuthenticatorAttestationResponseValidator;
use Webauthn\PublicKeyCredentialLoader;

$algorithmManager = Manager::create();
$algorithmManager->add(new ES256());

$attestationStatementSupportManager = AttestationStatementSupportManager::create();
$attestationStatementSupportManager->add(new NoneAttestationStatementSupport());
$attestationStatementSupportManager->add(new PackedAttestationStatementSupport($algorithmManager));

$extensionOutputCheckerHandler = ExtensionOutputCheckerHandler::create();

$publicKeyCredentialLoader = PublicKeyCredentialLoader::create(AttestationObjectLoader::create($attestationStatementSupportManager));
$authenticatorAttestationResponseValidator = AuthenticatorAttestationResponseValidator::create(
$attestationStatementSupportManager,
null,
null,
$extensionOutputCheckerHandler
);
$authenticatorAssertionResponseValidator = AuthenticatorAssertionResponseValidator::create(
null,
null,
$extensionOutputCheckerHandler,
$algorithmManager
);

Container::getInstance()->instance(PublicKeyCredentialLoader::class, $publicKeyCredentialLoader);
Container::getInstance()->instance(AuthenticatorAttestationResponseValidator::class, $authenticatorAttestationResponseValidator);
Container::getInstance()->instance(AuthenticatorAssertionResponseValidator::class, $authenticatorAssertionResponseValidator);

return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
->js(__DIR__ . '/js/dist/forum.js')
->css(__DIR__ . '/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/less/admin.less'),
new Extend\Locales(__DIR__.'/locale'),
->js(__DIR__ . '/js/dist/admin.js')
->css(__DIR__ . '/less/admin.less'),
new Extend\Locales(__DIR__ . '/locale'),

(new Extend\Routes('api'))
->get("/passkeys", "passkeys.index", Api\Controllers\ListPasskeyController::class)
->get('/passkeys/{id}', 'passkeys.show', Api\Controllers\ShowPasskeyController::class)
->patch("/passkeys/{id}", "passkeys.update", Api\Controllers\UpdatePasskeyController::class)
->delete("/passkeys/{id}", "passkeys.delete", Api\Controllers\DeletePasskeyController::class),
(new Extend\Routes('forum'))
->get("/authorization/passkey/registration/options", "authorization.passkey.registration.options", Controllers\PasskeyRegistrationOptionsController::class)
->post("/authorization/passkey/registration", "authorization.passkey.registration", Controllers\PasskeyRegistrationController::class)
->get("/authorization/passkey/assertion/options", "authorization.passkey.assertion.options", Controllers\PasskeyAssertionOptionsController::class)
->post("/authorization/passkey/assertion", "authorization.passkey.assertion", Controllers\PasskeyAssertionController::class),

(new Extend\Middleware('forum'))
->add(Middleware\ErrorHandler::class),

(new Extend\Settings)
->default("hikarilan-passkey-login.timeout", 60)
];
1 change: 1 addition & 0 deletions js/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
1 change: 0 additions & 1 deletion js/admin.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './src/common';
export * from './src/admin';
132 changes: 132 additions & 0 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit efb198c

Please sign in to comment.