This commit is contained in:
parent
cc3cf2619c
commit
f177475779
@ -22,26 +22,19 @@ app.use(session({
|
||||
}));
|
||||
|
||||
/* OIDC setup (lazy) */
|
||||
type OidcConfig = {
|
||||
issuer:string;
|
||||
clientId:string;
|
||||
clientSecret:string;
|
||||
redirectUri:string;
|
||||
providerName:string;
|
||||
};
|
||||
function loadOidcConfig():OidcConfig {
|
||||
const issuer = process.env.OIDC_ISSUER || '';
|
||||
const clientId = process.env.OIDC_CLIENT_ID || '';
|
||||
const clientSecret = process.env.OIDC_CLIENT_SECRET || '';
|
||||
const redirectUri = process.env.OIDC_REDIRECT_URI || '';
|
||||
const providerName = process.env.OIDC_PROVIDER || 'Identity Provider';
|
||||
if (!issuer || !clientId || !clientSecret || !redirectUri) {
|
||||
throw new Error('OIDC env vars incomplete (OIDC_ISSUER / OIDC_CLIENT_ID / OIDC_CLIENT_SECRET / OIDC_REDIRECT_URI)');
|
||||
type OidcConfig = { issuer:string; clientId:string; clientSecret:string; redirectUri:string; providerName:string; };
|
||||
function loadOidcConfig(): OidcConfig {
|
||||
const cfg = {
|
||||
issuer: process.env.OIDC_ISSUER || '',
|
||||
clientId: process.env.OIDC_CLIENT_ID || '',
|
||||
clientSecret: process.env.OIDC_CLIENT_SECRET || '',
|
||||
redirectUri: process.env.OIDC_REDIRECT_URI || '',
|
||||
providerName: process.env.OIDC_PROVIDER || 'Identity Provider'
|
||||
};
|
||||
if (!cfg.issuer || !cfg.clientId || !cfg.clientSecret || !cfg.redirectUri) {
|
||||
throw new Error('Missing OIDC env (OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET, OIDC_REDIRECT_URI)');
|
||||
}
|
||||
if (clientSecret.includes('replace-with-real-secret')) {
|
||||
log.warn('Using placeholder OIDC_CLIENT_SECRET – replace before production.');
|
||||
}
|
||||
return { issuer, clientId, clientSecret, redirectUri, providerName };
|
||||
return cfg;
|
||||
}
|
||||
const oidcCfg = loadOidcConfig();
|
||||
let oidcClient: Client | null = null;
|
||||
@ -178,6 +171,13 @@ app.get('/api/auth/config', (_req,res)=>{
|
||||
});
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT||8080);
|
||||
app.listen(port, ()=> log.info({
|
||||
port,
|
||||
oidc: { issuer: oidcCfg.issuer, redirect: oidcCfg.redirectUri, provider: oidcCfg.providerName }
|
||||
}, 'listening'));
|
||||
});
|
||||
|
||||
const port = Number(process.env.PORT||8080);
|
||||
app.listen(port, ()=> {
|
||||
log.info({
|
||||
|
@ -34,17 +34,19 @@ services:
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VITE_API_BASE: ${VITE_API_BASE:-http://localhost:8080}
|
||||
OIDC_PROVIDER: ${OIDC_PROVIDER:-AuthServer}
|
||||
VITE_OIDC_PROVIDER: ${OIDC_PROVIDER:-AuthServer}
|
||||
VITE_BING_MKT: ${VITE_BING_MKT:-en-US}
|
||||
VITE_BING_DISABLE: ${VITE_BING_DISABLE:-0}
|
||||
environment:
|
||||
VITE_API_BASE: ${VITE_API_BASE:-http://localhost:8080}
|
||||
OIDC_PROVIDER: ${OIDC_PROVIDER:-AuthServer}
|
||||
VITE_BING_MKT: ${VITE_BING_MKT:-en-US}
|
||||
VITE_BING_DISABLE: ${VITE_BING_DISABLE:-0}
|
||||
ports:
|
||||
- "5173:80"
|
||||
depends_on:
|
||||
- backend
|
||||
volumes:
|
||||
backend_data: {}
|
||||
- backend
|
||||
volumes:
|
||||
backend_data: {}
|
||||
|
@ -6,10 +6,12 @@ COPY index.html vite.config.ts tsconfig.json ./
|
||||
COPY src ./src
|
||||
ARG VITE_API_BASE
|
||||
ARG OIDC_PROVIDER
|
||||
ARG VITE_OIDC_PROVIDER
|
||||
ARG VITE_BING_MKT
|
||||
ARG VITE_BING_DISABLE
|
||||
ENV VITE_API_BASE=$VITE_API_BASE
|
||||
ENV OIDC_PROVIDER=$OIDC_PROVIDER
|
||||
ENV VITE_OIDC_PROVIDER=${VITE_OIDC_PROVIDER:-$OIDC_PROVIDER}
|
||||
ENV VITE_BING_MKT=$VITE_BING_MKT
|
||||
ENV VITE_BING_DISABLE=$VITE_BING_DISABLE
|
||||
RUN npm run build
|
||||
|
@ -10,6 +10,7 @@ interface Props {
|
||||
export const LoginScreen: React.FC<Props> = ({ theme, onToggleTheme, onLogin, market='en-US' }) => {
|
||||
const [bgUrl,setBgUrl] = useState<string|null>(null);
|
||||
const [attribution,setAttribution] = useState<string>('');
|
||||
const providerName = (import.meta.env.VITE_OIDC_PROVIDER as string) || 'Identity Provider';
|
||||
|
||||
useEffect(()=>{
|
||||
let cancelled = false;
|
||||
@ -27,8 +28,6 @@ export const LoginScreen: React.FC<Props> = ({ theme, onToggleTheme, onLogin, ma
|
||||
return ()=> { cancelled = true; };
|
||||
}, [market]);
|
||||
|
||||
const providerName: string = (typeof __OIDC_PROVIDER__ !== 'undefined' && __OIDC_PROVIDER__) || 'Identity Provider';
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position:'relative',
|
||||
@ -147,3 +146,4 @@ const iconButtonStyle: React.CSSProperties = {
|
||||
boxShadow:'0 4px 14px -4px rgba(0,0,0,0.4)',
|
||||
transition:'background .2s'
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user