Code Monkey home page Code Monkey logo

passport's Introduction

Passport by FriendsOfFlarum

MIT license Latest Stable Version Total Downloads

The Laravel Passport compatible oauth extension.

Installation

composer require fof/passport:*

Updating from Flagrow

This extension replaces Flagrow Passport.

To upgrade from the old extension to the new one:

  • Backup your data!

  • Disable the Passport extension in the admin panel.

  • Run:

composer require fof/passport:*

Composer should let you know that flagrow/passport has been automatically removed.

  • Enable the new extension in the admin panel.

  • Your existing settings will be migrated to FoF Passport automatically.

  • You should be good to go! All URLs stay the same.

Configuration

In the extension settings, you have to fill the following data:

Setting Example Description
OAuth authorization url https://example.com/oauth/authorize <your laravel install>/oauth/authorize
OAuth token url https://example.com/oauth/token <your laravel install>/oauth/token
Api URL providing user details when authenticated https://example.com/api/user Default Laravel installs have an /api/user route, otherwise point to a route returning the current user data (protected by the passport driver)
OAuth application id 1 The integer Client ID you've made in the Laravel app or via artisan passport:client
OAuth application secret abcdefghijABCDEFGHIJabcdefghijABCDEFGHIJ The Client secret provided by Laravel once you created the OAuth client
OAuth scopes to request Optional additional scopes to request during authorization, perhaps you want to protect the user url with a scope or add additional functionality
Label for login button Login with Example Label to place on the login button
Icon for login button far fa-id-card FontAwesome icon to place on the login button. List of available icons

Hint: When creating the OAuth client in your Laravel app, don't forget to set the redirect value to <your flarum install>/auth/passport or you might encounter invalid_client errors.

Links

An extension by FriendsOfFlarum

passport's People

Contributors

clarkwinkelmann avatar davwheat avatar dependabot[bot] avatar flarum-bot avatar imorland avatar karaok491 avatar luceos avatar vlntsolo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

passport's Issues

Removed your package and Flarum does not refresh the logout and activation status

Version Flarum Beta 16

I have just installed your latest package and could not get it to work unforunately.
I decided to remove it from the admin panel and now the logout sessions and account activations do not refresh their status unless I manually refresh the(reload) the page.

ie: I log out, the user profile still shows in the navbar, I refresh the page, the user name disappear.

Any idea how I can get the forum back to normal?

Thank you.

Bug with prepareToken

Uncaught TypeError: Argument 1 passed to League\\OAuth2\\Client\\Provider\\AbstractProvider::prepareAccessTokenResponse() must be of the type array, string given,

I am getting it on flarum/auth/passport

bug error.

Laravel version: 5.5.*,
flarum: beta7
passport: ^4.0

There was an error when I login.

Fatal error: Uncaught TypeError: Argument 1 passed to Flagrow\Passport\Providers\PassportProvider::createResourceOwner() must be of the type array, string given, called in /Users/hexu/learning/bbs/vendor/league/oauth2-client/src/Provider/AbstractProvider.php on line 778 and defined in /Users/hexu/learning/bbs/vendor/flagrow/passport/src/Providers/PassportProvider.php on line 93

Argument #2 ($identifier) must be of type string, null given

Bug Report

Current Behavior
After authorized in login.microsoftonline.com, thowing error and cannot continue.

Steps to Reproduce

  1. Click on Login with microsoft
  2. Authorize as microsoft asked.
  3. See error

Expected Behavior
Sucessfully authorized.

Logs

[2023-05-20 14:32:48] flarum.ERROR: TypeError: Flarum\Forum\Auth\ResponseFactory::make(): Argument #2 ($identifier) must be of type string, null given, called in /opt/www/xmccbbs/vendor/fof/passport/src/Controllers/PassportController.php on line 105 and defined in /opt/www/xmccbbs/vendor/flarum/core/src/Forum/Auth/ResponseFactory.php:36
Stack trace:
#0 /opt/www/xmccbbs/vendor/fof/passport/src/Controllers/PassportController.php(105): Flarum\Forum\Auth\ResponseFactory->make()
#1 /opt/www/xmccbbs/vendor/flarum/core/src/Http/RouteHandlerFactory.php(41): FoF\Passport\Controllers\PassportController->handle()
#2 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ExecuteRoute.php(27): Flarum\Http\RouteHandlerFactory->Flarum\Http\{closure}()
#3 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ExecuteRoute->process()
#4 /opt/www/xmccbbs/vendor/fof/discussion-language/src/Middleware/AddLanguageFilter.php(49): Laminas\Stratigility\Next->handle()
#5 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): FoF\DiscussionLanguage\Middleware\AddLanguageFilter->process()
#6 /opt/www/xmccbbs/vendor/fof/oauth/src/Middleware/ErrorHandler.php(50): Laminas\Stratigility\Next->handle()
#7 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): FoF\OAuth\Middleware\ErrorHandler->process()
#8 /opt/www/xmccbbs/vendor/fof/terms/src/Middlewares/RegisterMiddleware.php(59): Laminas\Stratigility\Next->handle()
#9 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): FoF\Terms\Middlewares\RegisterMiddleware->process()
#10 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ContentTypeOptionsHeader.php(21): Laminas\Stratigility\Next->handle()
#11 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ContentTypeOptionsHeader->process()
#12 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ReferrerPolicyHeader.php(30): Laminas\Stratigility\Next->handle()
#13 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ReferrerPolicyHeader->process()
#14 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/FlarumPromotionHeader.php(30): Laminas\Stratigility\Next->handle()
#15 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\FlarumPromotionHeader->process()
#16 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ShareErrorsFromSession.php(57): Laminas\Stratigility\Next->handle()
#17 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ShareErrorsFromSession->process()
#18 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/CheckCsrfToken.php(36): Laminas\Stratigility\Next->handle()
#19 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\CheckCsrfToken->process()
#20 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ResolveRoute.php(69): Laminas\Stratigility\Next->handle()
#21 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ResolveRoute->process()
#22 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/SetLocale.php(51): Laminas\Stratigility\Next->handle()
#23 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\SetLocale->process()
#24 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/AuthenticateWithSession.php(31): Laminas\Stratigility\Next->handle()
#25 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\AuthenticateWithSession->process()
#26 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/RememberFromCookie.php(52): Laminas\Stratigility\Next->handle()
#27 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\RememberFromCookie->process()
#28 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/StartSession.php(61): Laminas\Stratigility\Next->handle()
#29 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\StartSession->process()
#30 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/CollectGarbage.php(46): Laminas\Stratigility\Next->handle()
#31 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\CollectGarbage->process()
#32 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ParseJsonBody.php(28): Laminas\Stratigility\Next->handle()
#33 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ParseJsonBody->process()
#34 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/HandleErrors.php(57): Laminas\Stratigility\Next->handle()
#35 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\HandleErrors->process()
#36 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/InjectActorReference.php(25): Laminas\Stratigility\Next->handle()
#37 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\InjectActorReference->process()
#38 /opt/www/xmccbbs/vendor/fof/merge-discussions/src/Middleware/Redirection.php(28): Laminas\Stratigility\Next->handle()
#39 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): FoF\MergeDiscussions\Middleware\Redirection->process()
#40 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle()
#41 /opt/www/xmccbbs/vendor/middlewares/request-handler/src/RequestHandler.php(84): Laminas\Stratigility\MiddlewarePipe->process()
#42 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Middlewares\RequestHandler->process()
#43 /opt/www/xmccbbs/vendor/middlewares/base-path-router/src/BasePathRouter.php(101): Laminas\Stratigility\Next->handle()
#44 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Middlewares\BasePathRouter->process()
#45 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Middleware/OriginalMessages.php(36): Laminas\Stratigility\Next->handle()
#46 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Laminas\Stratigility\Middleware\OriginalMessages->process()
#47 /opt/www/xmccbbs/vendor/middlewares/base-path/src/BasePath.php(73): Laminas\Stratigility\Next->handle()
#48 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Middlewares\BasePath->process()
#49 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Middleware/ProcessIp.php(24): Laminas\Stratigility\Next->handle()
#50 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/Next.php(49): Flarum\Http\Middleware\ProcessIp->process()
#51 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(75): Laminas\Stratigility\Next->handle()
#52 /opt/www/xmccbbs/vendor/laminas/laminas-stratigility/src/MiddlewarePipe.php(64): Laminas\Stratigility\MiddlewarePipe->process()
#53 /opt/www/xmccbbs/vendor/laminas/laminas-httphandlerrunner/src/RequestHandlerRunner.php(73): Laminas\Stratigility\MiddlewarePipe->handle()
#54 /opt/www/xmccbbs/vendor/flarum/core/src/Http/Server.php(45): Laminas\HttpHandlerRunner\RequestHandlerRunner->run()
#55 /opt/www/xmccbbs/public/index.php(26): Flarum\Http\Server->listen()
#56 {main}

Screenshot
屏幕截图 2023-05-20 223457

Environment

  • Flarum version: 1.7.2
  • Extension version: 1.1.0
  • Website URL: https://bbs.xmcc.xrh0905.top
  • Webserver: apache2
  • Hosting environment: vps
  • PHP version: php-fpm 8.1
  • Browser: Edge
Flarum core: 1.7.2
PHP version: 8.1.18
MySQL version: 10.5.19-MariaDB-0+deb11u2
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, pcntl, Reflection, SPL, session, standard, sodium, mysqlnd, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, imap, intl, ldap, exif, msgpack, mysqli, pdo_mysql, pdo_sqlite, Phar, posix, readline, redis, shmop, SimpleXML, smbclient, sockets, sqlite3, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, memcached, libsmbclient, Zend OPcache
+--------------------------------+---------+--------+
| Flarum Extensions              |         |        |
+--------------------------------+---------+--------+
| ID                             | Version | Commit |
+--------------------------------+---------+--------+
| flarum-flags                   | v1.7.0  |        |
| flarum-approval                | v1.7.0  |        |
| flarum-subscriptions           | v1.7.0  |        |
| flarum-tags                    | v1.7.1  |        |
| flarum-nicknames               | v1.7.0  |        |
| flarum-suspend                 | v1.7.0  |        |
| fof-follow-tags                | 1.1.7   |        |
| zerosonesfun-direct-links      | 3.1     |        |
| v17development-seo             | v1.8.0  |        |
| pipecraft-id-slug              | v1.1.0  |        |
| glowingblue-password-strength  | 3.1.0   |        |
| ganuonglachanh-sonic           | 0.1.8   |        |
| fof-username-request           | 1.1.2   |        |
| fof-user-directory             | 1.2.3   |        |
| fof-user-bio                   | 1.1.0   |        |
| fof-upload                     | 1.2.3   |        |
| fof-terms                      | 1.2.1   |        |
| fof-subscribed                 | 1.1.3   |        |
| fof-split                      | 1.1.0   |        |
| fof-spamblock                  | 1.1.0   |        |
| fof-sitemap                    | 2.1.0   |        |
| fof-realtimelogin              | 1.0.0   |        |
| fof-reactions                  | 1.1.5   |        |
| fof-profile-image-crop         | 1.1.0   |        |
| fof-prevent-necrobumping       | 1.1.1   |        |
| fof-pretty-mail                | 1.1.1   |        |
| fof-polls                      | 1.3.0   |        |
| fof-passport                   | 1.1.0   |        |
| fof-oauth                      | 1.3.0   |        |
| fof-nightmode                  | 1.5.1   |        |
| fof-merge-discussions          | 1.3.1   |        |
| fof-links                      | 1.1.4   |        |
| fof-linguist                   | 1.1.1   |        |
| fof-impersonate                | 1.1.1   |        |
| fof-geoip                      | 1.1.0   |        |
| fof-formatting                 | 1.0.2   |        |
| fof-drafts                     | 1.2.2   |        |
| fof-discussion-language        | 1.2.9   |        |
| fof-default-user-preferences   | 1.2.0   |        |
| fof-default-group              | 1.1.1   |        |
| fof-custom-footer              | 1.1.0   |        |
| fof-best-answer                | 1.2.5   |        |
| fof-bbcode-tabs                | 1.0.3   |        |
| fof-bbcode-details             | 1.1.1   |        |
| fof-analytics                  | 1.1.0   |        |
| flarum-sticky                  | v1.7.0  |        |
| flarum-statistics              | v1.7.0  |        |
| flarum-mentions                | v1.7.0  |        |
| flarum-markdown                | v1.7.0  |        |
| flarum-lock                    | v1.7.0  |        |
| flarum-likes                   | v1.7.0  |        |
| flarum-lang-english            | v1.7.0  |        |
| flarum-lang-chinese-simplified | v1.2.0  |        |
| flarum-emoji                   | v1.7.0  |        |
| flarum-bbcode                  | v1.7.0  |        |
| clarkwinkelmann-author-change  | 1.0.3   |        |
| askvortsov-pwa                 | v3.3.3  |        |
| antoinefr-bbcode-fa            | v1.0.0  |        |
+--------------------------------+---------+--------+
Base URL: https://bbs.xmcc.xrh0905.top
Installation path: /opt/www/xmccbbs
Queue driver: sync
Session driver: file
Scheduler status: Active
Mail driver: mail
Debug mode: off

Possible solution(s)

Additional Context
Config:

OAuth Authorize Link
https://login.microsoftonline.com/common/oauth2/v2.0/authorize
OAuth Token Link
https://login.microsoftonline.com/common/oauth2/v2.0/token
OAuth Profile Link
https://graph.microsoft.com/oidc/userinfo
Scope
User.Read, profile, email, openid

Invalid response received from Authorization Server. Expected JSON.

Bug Report

Current Behavior
Gets invalid JSON response and throws error

Steps to Reproduce

  1. Go to '/auth/passport'
  2. Click on 'authorize'
  3. See error

Expected Behavior

Response is successful and redirects with user authenticated

Screenshots
Not needed to reproduce

Environment

  • Flarum version: 1.7.2
  • Extension version: 1.1.0
  • Webserver: apache
  • Hosting environment: vps
  • PHP version: 8.1.18
  • Browser: Firefox 113.0.1 ( 64 Bit Linux )
Flarum core: 1.7.2
PHP version: 8.1.18
MySQL version: 5.7.41-cll-lve
Loaded extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bz2, calendar, ctype, curl, hash, filter, ftp, gettext, json, iconv, SPL, pcntl, readline, Reflection, session, standard, mbstring, shmop, SimpleXML, tokenizer,xml, bcmath, dom, fileinfo, gd, geoip, imap, intl, exif, mysqli, mysqlnd, PDO, pdo_mysql, pdo_sqlite, pgsql, Phar,posix, soap, sockets, sodium, xmlreader, xmlwriter, xsl, zip, ionCube Loader, Zend OPcache
+----------------------+---------+--------+
| Flarum Extensions    |         |        |
+----------------------+---------+--------+
| ID                   | Version | Commit |
+----------------------+---------+--------+
| flarum-flags         | v1.7.0  |        |
| flarum-approval      | v1.7.0  |        |
| sycho-private-facade | v0.1.12 |        |
| fof-passport         | 1.1.0   |        |
| flarum-tags          | v1.7.1  |        |
| flarum-suspend       | v1.7.0  |        |
| flarum-subscriptions | v1.7.0  |        |
| flarum-sticky        | v1.7.0  |        |
| flarum-statistics    | v1.7.0  |        |
| flarum-mentions      | v1.7.0  |        |
| flarum-markdown      | v1.7.0  |        |
| flarum-lock          | v1.7.0  |        |
| flarum-likes         | v1.7.0  |        |
| flarum-lang-english  | v1.7.0  |        |
| flarum-emoji         | v1.7.0  |        |
| flarum-bbcode        | v1.7.0  |        |
| extiverse-mercury    | 0.2.0   |        |
| blomstra-fontawesome | 0.1.5   |        |
| bilgehanars-packman  | v1.1    |        |
+----------------------+---------+--------+
Base URL: https://ommitted
Installation path: /home/supersft/ommitted
Queue driver: sync
Session driver: file
Mail driver: mail
Debug mode: off

Possible solution(s)

Additional Context
This issue is present on Flarum 1.8.0

FR: Improve flexibility of extension

This is a feature request to improve the flexibility of the Passport extension and is primarily sourced from my experience catering this extension to support Phabricator for the new Solus Flarum-based Forums.

Issues

  1. Currently, there is no support for passing optional params (with any sort of replacers / keywords) for the app_user_url.
  2. ResourceOwner result only handles a response which has an array of key/vals which correspond to the id, email, and name of the user.
  3. Currently, there is no support for specifying what keys from the result should be used for the id, email, and name.

Why these are an issue

For Phabricator, the app_user_url is an endpoint ending with /user.whoami, which requires an access token to interact with an internal Conduit API. This access token is passed as a query param access_token. My change to this extension required changing the getResourceOwnerDetailsUrl function from:

return $this->settings->get('flagrow.passport.app_user_url');

To the following:

return $this->settings->get('flagrow.passport.app_user_url')."?access_token=".((string) $token->getToken());

Obviously this wouldn't be flexible if implemented exactly how I did, however I do propose a solution in the solutions section of this FR. Carrying on, essentially passing the token which we receive as $token->getToken() (to ensure it is a string) allows us to get to the state of being able to get information such as the following:

{
  "result": {
    "phid": "PHID-USER-(REDACTED)",
    "userName": "JoshStroblTest",
    "realName": "Joshua Strobl (Test)",
    "image": "I_AM_A_URL",
    "uri": "I_AM_A_URL",
    "roles": [
      "verified",
      "approved",
      "activated"
    ],
    "primaryEmail": "[email protected]"
  },
  "error_code": null,
  "error_info": null
}

As you can see, rather than a response with the keys (such as phid) being provided directly in the JSON as a key/val, it is nested within a "result" Object. To enable us to get the correct keys, I added a private $result as a variable, and added the following in the constructor:

$this->result = $response["result"];

Obviously this isn't ideal for a universal solution, it would probably make more sense for $this->response to change instead.

Now that we were getting the right results, I had to ensure the keys were being adjusted in ResourceOwner's getValueByKey function, since we get:

  1. phid instead of id
  2. primaryEmail instead of email
  3. userName instead of name

Additionally I needed to change our fetching of those keys to using $this->result instead.

Potential Solutions

For the current issue of there not being any support for optional params, I propose the addition of a setting, maybe flagrow.passport.app_user_url_params which gets parsed in getResourceOwnerDetailsUrl (or elsewhere). This would support a limited amount of keywords that would get replaced in the function, such as:

  • token which would be replaced with the value presented in $token->getToken()
  • resourceOwnerId which would return the value presented in $token->getResourceOwnerId()

As an example, the params could be set as access_token=:token (or whatever syntax sugar you'd want to add for the keywords).

For the current issue of not handling nested keys, there's two solutions that immediately come to my mind:

  1. Handling strictly the case of results being nested
  2. Iterating over the keys, breaking when you find either id or the corresponding id-equivelant we're looking for and if it's an Array / Object, iterate over its items, continuing down the tree.

For the current issue of solely checking for id, email, and name, we could default to those keys and provide further settings options for setting what we should look for / use as id, email, and name.


Hope this was found to be useful.

Support for WordPress

Hi There!

I want that plugin should authenticate easily using wordpress. Maybe a another FoF plugin for WordPress.
Also block the default registration method.

Blank page after returned to redirect url with error in console

Bug Report

Current Behavior
After completing the OAuth flow and the 'code' param is returned when redirected to the redirect url, i.e /auth/passport?code=

A blank page is returned with the below error in the console

passport?code={code was here}:1 Uncaught TypeError: Cannot read property 'app' of null
    at passport?code={code was here}:1
(anonymous) @ passport?code={code was here}:1

Which is referring to this part of the code
<script>window.close(); window.opener.app.authenticationComplete({"email":"{email was here}","token":"{token was here}","provided":["email"]});</script>

Environment

  • Flarum version: 1.0.4
  • Extension version: 1.0.0
  • Webserver: Apache
  • PHP version: 7.4.16
  • Browser: Chrome 91
Flarum core 1.0.4
PHP version: 7.4.16
Loaded extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, pcntl, readline, Reflection, SPL, session, standard, bz2, calendar, ctype, curl, dom, mbstring, fileinfo, ftp, gd,
 gettext, iconv, intl, json, exif, mysqlnd, PDO, Phar, SimpleXML, sockets, sodium, sqlite3, tokenizer, xml, xmlwriter, xsl, mysqli, pdo_mysql, pdo_sqlite, xmlreader, xmlrpc, imagick, zip,
mysql, Zend OPcache
+----------------------+---------+--------+
| Flarum Extensions    |         |        |
+----------------------+---------+--------+
| ID                   | Version | Commit |
+----------------------+---------+--------+
| flarum-flags         | v1.0.0  |        |
| fof-passport         | 1.0.0   |        |
| flarum-tags          | v1.0.3  |        |
| flarum-suspend       | v1.0.0  |        |
| flarum-subscriptions | v1.0.0  |        |
| flarum-sticky        | v1.0.0  |        |
| flarum-statistics    | v1.0.0  |        |
| flarum-mentions      | v1.0.0  |        |
| flarum-markdown      | v1.0.1  |        |
| flarum-lock          | v1.0.0  |        |
| flarum-likes         | v1.0.0  |        |
| flarum-lang-english  | v1.0.0  |        |
| flarum-emoji         | v1.0.0  |        |
| flarum-bbcode        | v1.0.0  |        |
| flarum-approval      | v1.0.0  |        |
+----------------------+---------+--------+

put a link in redirect page

Feature Request

When I completing the oauth in some browser which without supports to pop up window etc.,the account program will redirect to the redirect_url(<your flarum install>/auth/passport),but the redirect_url won't redirect to the target url(such as binding or register account),the page will stay in blank.

It result in that if I put the flarum in a webview of app(don't support multiple windows normally),the plugin can't work.

Some tips and a link to redirect to target page can be put in the page of redirect_url after authorizing,user can click to redirect manually.

Problems with Laravel 8 and Flarum Beta16

Hello,

I am unable to get the the autorization to work between Flarum and Laravel 8.
Is this package working with Laravel 8?

Here is my configuration:
Flarum:

    "devDependencies": {
        "flarum": "0.1.0-beta.16",
        "prettier": "^2.2.1"
    }

    "require": {
        "flarum/approval": "^0.1.0",
        "flarum/bbcode": "^0.1.0",
        "flarum/core": "^0.1.0",
        "flarum/emoji": "^0.1.0",
        "flarum/flags": "^0.1.0",
        "flarum/lang-english": "^0.1.0",
        "flarum/likes": "^0.1.0",
        "flarum/lock": "^0.1.0",
        "flarum/markdown": "^0.1.0",
        "flarum/mentions": "^0.1.0",
        "flarum/nicknames": "^0.1.0",
        "flarum/pusher": "^0.1.0",
        "flarum/statistics": "^0.1.0",
        "flarum/sticky": "^0.1.0",
        "flarum/subscriptions": "^0.1.0",
        "flarum/suspend": "^0.1.0",
        "flarum/tags": "^0.1.0",
        "fof/passport": "^0.6.0"
    },

Laravel:

   "require": {
        "php": "^7.3",
        "ext-dom": "*",
        "aws/aws-sdk-php": "^3.176.2",
        "fideloper/proxy": "^4.4.1",
        "fruitcake/laravel-cors": "^1.0.6",
        "guzzlehttp/guzzle": "^7.3.0",
        "laravel/cashier-paddle": "^1.4.4",
        "laravel/framework": "^8.34.0",
        "laravel/legacy-factories": "^1.1.0",
        "laravel/passport": "^10.1",
        "laravel/telescope": "^4.4.6",
        "laravel/tinker": "^2.6.1",
        "laravel/ui": "^3.2.0",
        "spatie/laravel-permission": "^3.18.0"
    },

I have installed Laravel in my public_html folder(and it is working well). I have also installed the passport feature.
Flarum is installed at http://mywebsite.dev/forum

This is the request sent from the "Authorize page" on the Flarum side(login button)

https://website.dev/oauth/authorize
?scope=
&state=6931b2103c6208d4e981c30e8a20dfaf
&response_type=code
&approval_prompt=auto
&redirect_uri=https%3A%2F%2Fwebsite.dev%2Fforum%2Fauth%2Fpassport
&client_id=7

The the popup keeps showing:
An error occurred while trying to load this page.

This is the client records in my laravel Database:

 `oauth_clients` (`id`, `user_id`, `name`, `secret`, `provider`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `created_at`, `updated_at`) 
VALUES (7, 10, 'Forum', '9cjUAcKvaJ7aEig0j6jz5F9HEw36qL6G86DEqonG', NULL, 'https://website.dev/forum/auth/passport', 1, 1, 0, '2021-05-15 16:07:19', '2021-05-15 16:07:19');

I really cannot work out why it ia not working.

Not well compatible with Office 365 Azure AD

In fact, in one place, Microsoft requires OAuth scopes to be provided. I try to use arrays of various formats to fill in the blanks in the extention. But none of them work. This may be caused by the difference between the scope keyword provided by Microsoft and the keyword in the plug-in.

Generally, I used "User.Read", "profile", "email", "openid" as the scope in my previous project experience.

I want to know why it fails.

image

Below is the wrong return URL
https://XXX.com/auth/passport?error=invalid_client&error_description=AADSTS650053%3a+The+application+%27CNHBSTU%27+asked+for+scope+%27profile%2cemail%2copenid%27+that+doesn%27t+exist+on+the+resource+%2700000003-0000-0000-c000-000000000000%27.+Contact+the+app+vendor.%0d%0aTrace+ID%3a+c967b574-eb7a-4842-afcd-9449cf4f8700%0d%0aCorrelation+ID%3a+f2112d68-9a02-4c66-978c-87dbc0d26627%0d%0aTimestamp%3a+2021-06-11+19%3a32%3a48Z&state=f3b7f1201a4896f59048d2952a97fcd9#

Add option to replace default flarum login in header with FoF Passport

One of the applications of this extension might be external user management system for one or more Flarum instances. In this case one might need to hide default Flarum user management modals and restrict authentication to OAuth server only.

It might be handy to have additional boolean setting in extension admin area for this flow.

Front-end forum/index.js can have additional block:

import HeaderSecondary from "flarum/components/HeaderSecondary";
import SettingsPage from "flarum/components/SettingsPage";

app.initializers.add('fof-passport', () => {
 //....
 //Removes Flarum default header signUp logIn links and ads OAuth button
 extend(HeaderSecondary.prototype, 'items', function(items) {
  //If user isn't logged in displays FoF Passport LogIn button
  if (!app.session.user) {
    items.add('fof-passport', LogInButton.component({
        className: 'Button LogInButton--passport',
        icon: app.forum.attribute('fof-passport.loginIcon'),
        path: '/auth/passport',
        children: app.forum.attribute('fof-passport.loginTitle'),
    }));
  }
//Remove Login and signUp buttons
    items.remove("logIn");
    items.remove("signUp");
 });
 //Remove account details change buttons from profile
 extend(SettingsPage.prototype, 'accountItems', function(items) {
   items.remove('changeEmail');
   items.remove('changePassword');
 });

});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.