-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2c8bd07
Showing
11 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "cpluscc/oauth-misskey", | ||
"description": "Log in to your Flarum forum with Amazon", | ||
"keywords": [ | ||
"flarum", "amazon", "sso", "oauth", "login" | ||
], | ||
"type": "flarum-extension", | ||
"license": "MIT", | ||
"support": { | ||
|
||
}, | ||
"require": { | ||
"flarum/core": "^1.2.0", | ||
"fof/oauth": "^1.3.0", | ||
"cpluscc/oauth2-misskey": "*" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Cpluscc", | ||
"homepage": "https://post.cplus8.com" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Cpluscc\\OAuthMisskey\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "Log In With Misskey", | ||
"category": "feature", | ||
"icon": { | ||
"name": "fab fa-amazon", | ||
"backgroundColor": "#0072e3", | ||
"color": "#fff" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a fork of ianm/oauth-amazon. | ||
* | ||
* Copyright (c) 2021 IanM. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cpluscc\OAuthMisskey; | ||
|
||
use Flarum\Extend; | ||
use FoF\OAuth\Extend as OAuthExtend; | ||
use Cpluscc\OAuthMisskey\Providers\Misskey; | ||
|
||
return [ | ||
(new Extend\Frontend('forum')) | ||
->css(__DIR__.'/less/forum.less'), | ||
|
||
(new Extend\Frontend('admin')) | ||
->js(__DIR__.'/js/dist/admin.js'), | ||
|
||
new Extend\Locales(__DIR__.'/locale'), | ||
|
||
(new OAuthExtend\RegisterProvider(Misskey::class)), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './src/admin'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@cpluscc/oauth-misskey", | ||
"version": "0.0.0", | ||
"private": true, | ||
"prettier": "@flarum/prettier-config", | ||
"dependencies": { | ||
"flarum-webpack-config": "^2.0.0", | ||
"flarum-tsconfig": "^1.0.2", | ||
"@flarum/prettier-config": "^1.0.0", | ||
"webpack": "^5.72.1", | ||
"webpack-cli": "^4.9.2" | ||
}, | ||
"devDependencies": { | ||
"prettier": "^2.6.2" | ||
}, | ||
"scripts": { | ||
"dev": "webpack --mode development --watch", | ||
"build": "webpack --mode production", | ||
"format": "prettier --write src", | ||
"format-check": "prettier --check src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use Flarum's tsconfig as a starting point | ||
"extends": "flarum-tsconfig", | ||
// This will match all .ts, .tsx, .d.ts, .js, .jsx files in your `src` folder | ||
// and also tells your Typescript server to read core's global typings for | ||
// access to `dayjs` and `$` in the global namespace. | ||
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"], | ||
"compilerOptions": { | ||
// This will output typings to `dist-typings` | ||
"declarationDir": "./dist-typings", | ||
"baseUrl": ".", | ||
"paths": { | ||
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = require('flarum-webpack-config')({ | ||
useExtensions: ['fof-oauth'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.LogInButton--misskey { | ||
border-top-color: rgb(168, 135, 52); | ||
border-right-color: rgb(156, 126, 49); | ||
border-bottom-color: rgb(132, 106, 41); | ||
border-left-color: rgb(156, 126, 49); | ||
border-width: 1px; | ||
|
||
.Button--color(#000, #f0c14b); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
fof-oauth: | ||
admin: | ||
settings: | ||
providers: | ||
misskey: | ||
description: Register your forum with the Misskey Developer Portal {link} | ||
|
||
client_id_label: => fof-oauth.ref.settings.client_id | ||
client_secret_label: => fof-oauth.ref.settings.client_secret | ||
|
||
forum: | ||
log_in: | ||
with_misskey_button: '=> fof-oauth.forum.log_in.with_button' | ||
|
||
providers: | ||
amazon: '=> fof-oauth.lib.providers.misskey' | ||
|
||
lib: | ||
providers: | ||
amazon: Misskey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/* | ||
* This file is a fork of ianm/oauth-amazon. | ||
* | ||
* Copyright (c) 2021 IanM. | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Cpluscc\OAuthMisskey\Providers; | ||
|
||
use Flarum\Forum\Auth\Registration; | ||
use FoF\OAuth\Provider; | ||
use League\OAuth2\Client\Provider\AbstractProvider; | ||
use Cpluscc\OAuth2\Client\Provider\Misskey as MisskeyProvider; | ||
use Cpluscc\OAuth2\Client\Provider\MisskeyResourceOwner; | ||
|
||
class Misskey extends Provider | ||
{ | ||
/** | ||
* @var MisskeyProvider | ||
*/ | ||
protected $provider; | ||
|
||
public function name(): string | ||
{ | ||
return 'misskey'; | ||
} | ||
|
||
public function link(): string | ||
{ | ||
return 'https://developer.amazon.com/docs/login-with-amazon/register-web.html'; | ||
} | ||
|
||
public function fields(): array | ||
{ | ||
return [ | ||
'client_id' => 'required', | ||
'client_secret' => 'required', | ||
]; | ||
} | ||
|
||
public function provider(string $redirectUri): AbstractProvider | ||
{ | ||
return $this->provider = new MisskeyProvider([ | ||
'clientId' => $this->getSetting('client_id'), | ||
'clientSecret' => $this->getSetting('client_secret'), | ||
'redirectUri' => $redirectUri, | ||
]); | ||
} | ||
|
||
public function suggestions(Registration $registration, $user, string $token) | ||
{ | ||
/** @var MisskeyResourceOwner $user */ | ||
$this->verifyEmail($email = $user->getEmail()); | ||
|
||
$registration | ||
->provideTrustedEmail($email) | ||
->setPayload($user->toArray()); | ||
} | ||
} |