oidc登录按钮支持自定义文字
This commit is contained in:
@@ -311,6 +311,7 @@ interface SiteConfig {
|
|||||||
OIDCUserInfoEndpoint?: string;
|
OIDCUserInfoEndpoint?: string;
|
||||||
OIDCClientId?: string;
|
OIDCClientId?: string;
|
||||||
OIDCClientSecret?: string;
|
OIDCClientSecret?: string;
|
||||||
|
OIDCButtonText?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视频源数据类型
|
// 视频源数据类型
|
||||||
@@ -4605,6 +4606,7 @@ const SiteConfigComponent = ({
|
|||||||
OIDCUserInfoEndpoint: '',
|
OIDCUserInfoEndpoint: '',
|
||||||
OIDCClientId: '',
|
OIDCClientId: '',
|
||||||
OIDCClientSecret: '',
|
OIDCClientSecret: '',
|
||||||
|
OIDCButtonText: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 豆瓣数据源相关状态
|
// 豆瓣数据源相关状态
|
||||||
@@ -4686,6 +4688,7 @@ const SiteConfigComponent = ({
|
|||||||
OIDCUserInfoEndpoint: config.SiteConfig.OIDCUserInfoEndpoint || '',
|
OIDCUserInfoEndpoint: config.SiteConfig.OIDCUserInfoEndpoint || '',
|
||||||
OIDCClientId: config.SiteConfig.OIDCClientId || '',
|
OIDCClientId: config.SiteConfig.OIDCClientId || '',
|
||||||
OIDCClientSecret: config.SiteConfig.OIDCClientSecret || '',
|
OIDCClientSecret: config.SiteConfig.OIDCClientSecret || '',
|
||||||
|
OIDCButtonText: config.SiteConfig.OIDCButtonText || '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [config]);
|
}, [config]);
|
||||||
@@ -5721,6 +5724,28 @@ const SiteConfigComponent = ({
|
|||||||
这是系统自动生成的回调地址,基于环境变量SITE_BASE。请在OIDC提供商(如Keycloak、Auth0等)的应用配置中添加此地址作为允许的重定向URI
|
这是系统自动生成的回调地址,基于环境变量SITE_BASE。请在OIDC提供商(如Keycloak、Auth0等)的应用配置中添加此地址作为允许的重定向URI
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
{/* 操作按钮 */}
|
{/* 操作按钮 */}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export async function POST(request: NextRequest) {
|
|||||||
OIDCUserInfoEndpoint,
|
OIDCUserInfoEndpoint,
|
||||||
OIDCClientId,
|
OIDCClientId,
|
||||||
OIDCClientSecret,
|
OIDCClientSecret,
|
||||||
|
OIDCButtonText,
|
||||||
} = body as {
|
} = body as {
|
||||||
SiteName: string;
|
SiteName: string;
|
||||||
Announcement: string;
|
Announcement: string;
|
||||||
@@ -88,6 +89,7 @@ export async function POST(request: NextRequest) {
|
|||||||
OIDCUserInfoEndpoint?: string;
|
OIDCUserInfoEndpoint?: string;
|
||||||
OIDCClientId?: string;
|
OIDCClientId?: string;
|
||||||
OIDCClientSecret?: string;
|
OIDCClientSecret?: string;
|
||||||
|
OIDCButtonText?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 参数校验
|
// 参数校验
|
||||||
@@ -120,7 +122,8 @@ export async function POST(request: NextRequest) {
|
|||||||
(OIDCTokenEndpoint !== undefined && typeof OIDCTokenEndpoint !== 'string') ||
|
(OIDCTokenEndpoint !== undefined && typeof OIDCTokenEndpoint !== 'string') ||
|
||||||
(OIDCUserInfoEndpoint !== undefined && typeof OIDCUserInfoEndpoint !== 'string') ||
|
(OIDCUserInfoEndpoint !== undefined && typeof OIDCUserInfoEndpoint !== 'string') ||
|
||||||
(OIDCClientId !== undefined && typeof OIDCClientId !== '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 });
|
return NextResponse.json({ error: '参数格式错误' }, { status: 400 });
|
||||||
}
|
}
|
||||||
@@ -169,6 +172,7 @@ export async function POST(request: NextRequest) {
|
|||||||
OIDCUserInfoEndpoint,
|
OIDCUserInfoEndpoint,
|
||||||
OIDCClientId,
|
OIDCClientId,
|
||||||
OIDCClientSecret,
|
OIDCClientSecret,
|
||||||
|
OIDCButtonText,
|
||||||
};
|
};
|
||||||
|
|
||||||
// 写入数据库
|
// 写入数据库
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export async function POST(request: NextRequest) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let oidcSession;
|
let oidcSession: any;
|
||||||
try {
|
try {
|
||||||
oidcSession = JSON.parse(oidcSessionCookie);
|
oidcSession = JSON.parse(oidcSessionCookie);
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export async function GET(request: NextRequest) {
|
|||||||
TurnstileSiteKey: config.SiteConfig.TurnstileSiteKey || '',
|
TurnstileSiteKey: config.SiteConfig.TurnstileSiteKey || '',
|
||||||
EnableOIDCLogin: config.SiteConfig.EnableOIDCLogin || false,
|
EnableOIDCLogin: config.SiteConfig.EnableOIDCLogin || false,
|
||||||
EnableOIDCRegistration: config.SiteConfig.EnableOIDCRegistration || false,
|
EnableOIDCRegistration: config.SiteConfig.EnableOIDCRegistration || false,
|
||||||
|
OIDCButtonText: config.SiteConfig.OIDCButtonText || '',
|
||||||
};
|
};
|
||||||
return NextResponse.json(result);
|
return NextResponse.json(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ function LoginPageClient() {
|
|||||||
<svg className='w-5 h-5 mr-2' fill='currentColor' viewBox='0 0 20 20'>
|
<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' />
|
<path fillRule='evenodd' d='M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z' clipRule='evenodd' />
|
||||||
</svg>
|
</svg>
|
||||||
使用OIDC登录
|
{siteConfig?.OIDCButtonText || '使用OIDC登录'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ export interface AdminConfig {
|
|||||||
OIDCUserInfoEndpoint?: string; // 用户信息端点
|
OIDCUserInfoEndpoint?: string; // 用户信息端点
|
||||||
OIDCClientId?: string; // OIDC Client ID
|
OIDCClientId?: string; // OIDC Client ID
|
||||||
OIDCClientSecret?: string; // OIDC Client Secret
|
OIDCClientSecret?: string; // OIDC Client Secret
|
||||||
|
OIDCButtonText?: string; // OIDC登录按钮文字
|
||||||
};
|
};
|
||||||
UserConfig: {
|
UserConfig: {
|
||||||
Users: {
|
Users: {
|
||||||
|
|||||||
Reference in New Issue
Block a user