feat(auth): Add Oauth configuration for Telegram, Facebook, Google, Github, and Apple

This commit is contained in:
web@ppanel
2025-01-19 20:43:35 +07:00
parent cefcb310d6
commit 18ee600836
133 changed files with 2391 additions and 24 deletions
+38
View File
@@ -226,6 +226,44 @@ export async function updateNodeConfig(body: API.NodeConfig, options?: { [key: s
});
}
/** Get OAuth config GET /v1/admin/system/oauth_config */
export async function getOAuthConfig(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.OAuthQueryResponse }>(
'/v1/admin/system/oauth_config',
{
method: 'GET',
...(options || {}),
},
);
}
/** Update oauth config PUT /v1/admin/system/oauth_config */
export async function updateOAuthConfig(body: API.OAuthConfig, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/admin/system/oauth_config', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** OAuth create config POST /v1/admin/system/oauth_config */
export async function oAuthCreateConfig(
body: API.OAuthCreateRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/admin/system/oauth_config', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Get register config GET /v1/admin/system/register_config */
export async function getRegisterConfig(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.RegisterConfig }>('/v1/admin/system/register_config', {
+27
View File
@@ -123,6 +123,7 @@ declare namespace API {
name: string;
description: string;
subscribe_type: string;
platform: ApplicationPlatform;
};
type CreateApplicationVersionRequest = {
@@ -618,6 +619,31 @@ declare namespace API {
last_at: number;
};
type OAuthConfig = {
id: number;
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
team_id: string;
key_id: string;
client_id: string;
client_secret: string;
redirect: string;
enabled: boolean;
};
type OAuthCreateRequest = {
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
team_id: string;
key_id: string;
client_id: string;
client_secret: string;
enabled: boolean;
redirect: string;
};
type OAuthQueryResponse = {
list: OAuthConfig[];
};
type OnlineUser = {
uid: number;
ip: string;
@@ -1027,6 +1053,7 @@ declare namespace API {
name: string;
description: string;
subscribe_type: string;
platform: ApplicationPlatform;
};
type UpdateApplicationVersionRequest = {
+3 -1
View File
@@ -1,10 +1,12 @@
// @ts-ignore
/* eslint-disable */
// API 更新时间:
// API 唯一标识:
import * as auth from './auth';
import * as common from './common';
import * as oauth from './oauth';
export default {
auth,
oauth,
common,
};
+47
View File
@@ -0,0 +1,47 @@
// @ts-ignore
/* eslint-disable */
import request from '@/utils/request';
/** Apple Login Callback POST /v1/auth/oauth/callback/apple */
export async function appleLoginCallback(options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/apple', {
method: 'POST',
...(options || {}),
});
}
/** Facebook Login Callback GET /v1/auth/oauth/callback/facebook */
export async function facebookLoginCallback(options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/facebook', {
method: 'GET',
...(options || {}),
});
}
/** Google Login Callback GET /v1/auth/oauth/callback/google */
export async function googleLoginCallback(options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/google', {
method: 'GET',
...(options || {}),
});
}
/** Telegram Login Callback GET /v1/auth/oauth/callback/telegram */
export async function telegramLoginCallback(options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/auth/oauth/callback/telegram', {
method: 'GET',
...(options || {}),
});
}
/** OAuth login POST /v1/auth/oauth/login */
export async function oAuthLogin(body: API.OAthLoginRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.OAuthLoginResponse }>('/v1/auth/oauth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
+20
View File
@@ -205,6 +205,26 @@ declare namespace API {
last_at: number;
};
type OAthLoginRequest = {
/** google, facebook, apple, telegram, github etc. */
method: string;
};
type OAuthConfig = {
id: number;
platform: 'github' | 'google' | 'apple' | 'qq' | 'wechat' | 'telegram' | 'facebook';
team_id: string;
key_id: string;
client_id: string;
client_secret: string;
redirect: string;
enabled: boolean;
};
type OAuthLoginResponse = {
redirect: string;
};
type OnlineUser = {
uid: number;
ip: string;