承接 czmgxr/flarum-oauth-passport-fork 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

czmgxr/flarum-oauth-passport-fork

Composer 安装命令:

composer require czmgxr/flarum-oauth-passport-fork

包简介

Passport OAuth provider for Flarum - standalone implementation

README 文档

README

License Latest Stable Version Total Downloads Flarum

English | 简体中文

A standalone Flarum extension that enables OAuth2 authentication via Laravel Passport or any OAuth2-compatible server. No fof/oauth dependency required - full control over the OAuth flow with a custom callback route at /auth/passport.

screenshot

Features

  • Standalone Implementation: No dependency on fof/oauth - complete control over the OAuth flow
  • Universal OAuth2 Support: Works with Laravel Passport, Keycloak, Auth0, or any standard OAuth2 server
  • Flexible User Data Mapping: Configure field names for ID, display name, and email (supports dot notation for nested JSON)
  • Customizable Login Button: Set custom title, icon (FontAwesome), background color, and text color
  • Account Linking: Automatic account linking via OAuth provider ID
  • Profile Synchronization: Optionally update display name and email on subsequent logins
  • Passwordless Option: Hide default username/password fields for pure OAuth authentication
  • Popup Configuration: Fullscreen popup or custom width/height for OAuth window
  • In-App Browser Support: Built-in fallback for WeChat and other in-app browsers
  • Migration Support: Seamless migration from blt950/oauth-generic and fof/passport

Installation

composer require import-ai/flarum-oauth-passport

Upgrade

composer update import-ai/flarum-oauth-passport
php flarum migrate
php flarum cache:clear

Configuration

  1. Navigate to Administration > Extensions > OAuth Passport
  2. Copy the Redirect URL to your OAuth server's allowed redirect URLs
  3. Configure OAuth endpoints and credentials (see below)

OAuth Server Settings

SettingDescription
Client IDYour OAuth application client ID
Client SecretYour OAuth application client secret
ScopesComma-separated OAuth scopes (default: read)
Authorization EndpointOAuth authorize URL (e.g., https://auth.example.com/oauth/authorize)
Token EndpointOAuth token URL (e.g., https://auth.example.com/oauth/token)
User Information EndpointUser info URL (e.g., https://auth.example.com/api/user)

User Data Mapping

Configure the field names from your OAuth server's user info response:

SettingDefaultDot Notation Support
User ID FieldidYes (e.g., data.user.id)
Display Name FieldnameYes (e.g., data.name)
Email Address FieldemailYes (e.g., data.email)

User Registration Options

SettingDescription
Force User ID as UsernameUse OAuth user ID as Flarum username instead of allowing user to choose
Force Display NameUse OAuth display name instead of allowing user to choose
Force Email AddressUse OAuth email and mark as verified
Update Display Name on LoginSync display name from OAuth server on each login
Update Email on LoginSync email from OAuth server on each login

Login Button Customization

SettingDefaultDescription
Button Title"Login with Passport"Text displayed on the login button
Button Iconfas fa-passportFontAwesome icon class
Button Background Color#3B82F6Hex color code
Button Text Color#ffffffHex color code

Popup Settings

SettingDefaultDescription
Fullscreen PopupfalseUse fullscreen popup for OAuth (ignores width/height)
Popup Width580OAuth popup window width in pixels
Popup Height400OAuth popup window height in pixels

Advanced Options

  • Replace Login/Signup Buttons: Hide default username/password fields and show only the OAuth button

OAuth Flow

  1. User clicks "Login with Passport" button
  2. Extension redirects to OAuth server with state parameter (CSRF protection)
  3. User authenticates on OAuth server
  4. OAuth server redirects back to /auth/passport?code=xxx&state=xxx
  5. Extension validates state and exchanges code for access token
  6. Extension fetches user info and creates/logs in Flarum user
  7. Optional: Dispatches OAuthLoginSuccessful event for custom handling

Migration from Other Extensions

This extension includes built-in migrations for:

  • blt950/oauth-generic
  • fof/passport

Simply install this extension and existing OAuth-linked accounts will continue to work.

Events

The extension dispatches FoF\Extend\Events\OAuthLoginSuccessful after a successful OAuth login, allowing other extensions to perform custom actions:

use FoF\Extend\Events\OAuthLoginSuccessful;

$events->listen(OAuthLoginSuccessful::class, function (OAuthLoginSuccessful $event) {
    $token = $event->token;        // AccessToken from League\OAuth2\Client
    $user = $event->user;          // ResourceOwnerInterface
    $provider = $event->provider;  // 'passport'
    $providerId = $event->providerId;
    $actor = $event->actor;        // Current user (null if guest)
});

In-App Browser Support

For environments like WeChat where popups are blocked, the extension includes middleware that detects in-app browsers and provides a fallback mechanism for completing OAuth authentication.

Requirements

  • Flarum 1.2.0 or higher
  • PHP 7.4 or higher
  • An OAuth2-compatible authentication server

Links

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-06-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固