oidc登录按钮支持自定义文字

This commit is contained in:
mtvpls
2025-12-13 17:36:57 +08:00
parent 822bb4a07e
commit d467c5067b
6 changed files with 34 additions and 3 deletions

View File

@@ -311,6 +311,7 @@ interface SiteConfig {
OIDCUserInfoEndpoint?: string;
OIDCClientId?: string;
OIDCClientSecret?: string;
OIDCButtonText?: string;
}
// 视频源数据类型
@@ -4605,6 +4606,7 @@ const SiteConfigComponent = ({
OIDCUserInfoEndpoint: '',
OIDCClientId: '',
OIDCClientSecret: '',
OIDCButtonText: '',
});
// 豆瓣数据源相关状态
@@ -4686,6 +4688,7 @@ const SiteConfigComponent = ({
OIDCUserInfoEndpoint: config.SiteConfig.OIDCUserInfoEndpoint || '',
OIDCClientId: config.SiteConfig.OIDCClientId || '',
OIDCClientSecret: config.SiteConfig.OIDCClientSecret || '',
OIDCButtonText: config.SiteConfig.OIDCButtonText || '',
});
}
}, [config]);
@@ -5721,6 +5724,28 @@ const SiteConfigComponent = ({
SITE_BASEOIDC提供商KeycloakAuth0等URI
</p>
</div>
{/* OIDC登录按钮文字 */}
<div>
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
OIDC登录按钮文字
</label>
<input
type='text'
placeholder='使用OIDC登录'
value={siteSettings.OIDCButtonText || ''}
onChange={(e) =>
setSiteSettings((prev) => ({
...prev,
OIDCButtonText: e.target.value,
}))
}
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-green-500 focus:border-transparent'
/>
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
OIDC登录按钮显示的文字"使用企业账号登录""使用SSO登录""使用OIDC登录"
</p>
</div>
</div>
{/* 操作按钮 */}

View File

@@ -58,6 +58,7 @@ export async function POST(request: NextRequest) {
OIDCUserInfoEndpoint,
OIDCClientId,
OIDCClientSecret,
OIDCButtonText,
} = body as {
SiteName: string;
Announcement: string;
@@ -88,6 +89,7 @@ export async function POST(request: NextRequest) {
OIDCUserInfoEndpoint?: string;
OIDCClientId?: string;
OIDCClientSecret?: string;
OIDCButtonText?: string;
};
// 参数校验
@@ -120,7 +122,8 @@ export async function POST(request: NextRequest) {
(OIDCTokenEndpoint !== undefined && typeof OIDCTokenEndpoint !== 'string') ||
(OIDCUserInfoEndpoint !== undefined && typeof OIDCUserInfoEndpoint !== 'string') ||
(OIDCClientId !== undefined && typeof OIDCClientId !== 'string') ||
(OIDCClientSecret !== undefined && typeof OIDCClientSecret !== 'string')
(OIDCClientSecret !== undefined && typeof OIDCClientSecret !== 'string') ||
(OIDCButtonText !== undefined && typeof OIDCButtonText !== 'string')
) {
return NextResponse.json({ error: '参数格式错误' }, { status: 400 });
}
@@ -169,6 +172,7 @@ export async function POST(request: NextRequest) {
OIDCUserInfoEndpoint,
OIDCClientId,
OIDCClientSecret,
OIDCButtonText,
};
// 写入数据库

View File

@@ -73,7 +73,7 @@ export async function POST(request: NextRequest) {
);
}
let oidcSession;
let oidcSession: any;
try {
oidcSession = JSON.parse(oidcSessionCookie);
} catch {

View File

@@ -43,6 +43,7 @@ export async function GET(request: NextRequest) {
TurnstileSiteKey: config.SiteConfig.TurnstileSiteKey || '',
EnableOIDCLogin: config.SiteConfig.EnableOIDCLogin || false,
EnableOIDCRegistration: config.SiteConfig.EnableOIDCRegistration || false,
OIDCButtonText: config.SiteConfig.OIDCButtonText || '',
};
return NextResponse.json(result);
}

View File

@@ -362,7 +362,7 @@ function LoginPageClient() {
<svg className='w-5 h-5 mr-2' fill='currentColor' viewBox='0 0 20 20'>
<path fillRule='evenodd' d='M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z' clipRule='evenodd' />
</svg>
使OIDC登录
{siteConfig?.OIDCButtonText || '使用OIDC登录'}
</button>
</div>
)}

View File

@@ -40,6 +40,7 @@ export interface AdminConfig {
OIDCUserInfoEndpoint?: string; // 用户信息端点
OIDCClientId?: string; // OIDC Client ID
OIDCClientSecret?: string; // OIDC Client Secret
OIDCButtonText?: string; // OIDC登录按钮文字
};
UserConfig: {
Users: {