mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-21 04:04:46 +08:00

### What problem does this PR solve? Deprecate `/github_callback` route in favor of `/oauth/callback/<channel>` for GitHub OAuth integration: - Added GitHub OAuth support in the authentication module - Introduced `GithubOAuthClient` with methods to fetch and normalize user info - Updated `CLIENT_TYPES` to include GitHub OAuth client - Deprecated `/github_callback` route and suggested using the generic `/oauth/callback/<channel>` route --- - Related pull requests: - #7379 - #7553 ### Usage - [Create a GitHub OAuth App](https://github.com/settings/applications/new) to obtain the `client_id` and `client_secret`, configure the authorization callback url: `https://your-app.com/v1/user/oauth/callback/github` - Edit `service_conf.yaml.template`: ```yaml # ... oauth: github: type: "github" icon: "github" display_name: "Github" client_id: "your_client_id" client_secret: "your_client_secret" redirect_uri: "https://your-app.com/v1/user/oauth/callback/github" # ... ``` ### Type of change - [x] Documentation Update - [x] Refactoring (non-breaking change)
41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#
|
|
# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
|
|
from .oauth import OAuthClient
|
|
from .oidc import OIDCClient
|
|
from .github import GithubOAuthClient
|
|
|
|
|
|
CLIENT_TYPES = {
|
|
"oauth2": OAuthClient,
|
|
"oidc": OIDCClient,
|
|
"github": GithubOAuthClient
|
|
}
|
|
|
|
|
|
def get_auth_client(config)->OAuthClient:
|
|
channel_type = str(config.get("type", "")).lower()
|
|
if channel_type == "":
|
|
if config.get("issuer"):
|
|
channel_type = "oidc"
|
|
else:
|
|
channel_type = "oauth2"
|
|
client_class = CLIENT_TYPES.get(channel_type)
|
|
if not client_class:
|
|
raise ValueError(f"Unsupported type: {channel_type}")
|
|
|
|
return client_class(config)
|