Skip to content

Commit cc1b665

Browse files
fix eslint error
1 parent f14318c commit cc1b665

9 files changed

Lines changed: 79 additions & 61 deletions

File tree

api/server/controllers/AuthController.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ const resetPasswordController = async (req, res) => {
7474
* @param {string} [tokenProvider] - 'solid' or 'openid' from cookie so setOpenIDAuthTokens sets the correct token_provider cookie
7575
* @returns {Promise<boolean>} True if response was sent, false if caller should continue to next handler
7676
*/
77-
async function performOpenIDRefresh(req, res, openIdConfig, refreshToken, refreshParams = {}, tokenProvider) {
77+
async function performOpenIDRefresh(
78+
req,
79+
res,
80+
openIdConfig,
81+
refreshToken,
82+
refreshParams = {},
83+
tokenProvider,
84+
) {
7885
try {
7986
const tokenset = await openIdClient.refreshTokenGrant(
8087
openIdConfig,
@@ -198,7 +205,9 @@ const refreshController = async (req, res) => {
198205
try {
199206
return getOpenIdConfig();
200207
} catch (e) {
201-
logger.warn('[refreshController] OpenID config not initialized', { message: e?.message });
208+
logger.warn('[refreshController] OpenID config not initialized', {
209+
message: e?.message,
210+
});
202211
return null;
203212
}
204213
})();

api/server/controllers/auth/solidOpenIdDynamic.js

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ async function startSolidOpenIdFlow(req, res, next) {
6868

6969
const provider = getSolidOpenIdProviderByIssuer(issuer.trim());
7070
if (!provider) {
71-
logger.warn('[solidOpenIdDynamic] Unknown or unconfigured issuer', { issuer: issuer.slice(0, 80) });
72-
res.status(400).send('Unknown or unconfigured Solid Identity Provider. Use one of the options from the login page.');
71+
logger.warn('[solidOpenIdDynamic] Unknown or unconfigured issuer', {
72+
issuer: issuer.slice(0, 80),
73+
});
74+
res
75+
.status(400)
76+
.send(
77+
'Unknown or unconfigured Solid Identity Provider. Use one of the options from the login page.',
78+
);
7379
return;
7480
}
7581

@@ -151,10 +157,13 @@ async function handleSolidOpenIdCallback(req, res, next) {
151157
if (!code) {
152158
const errParam = req.query.error;
153159
const errDesc = req.query.error_description;
154-
logger.warn('[solidOpenIdDynamic] Callback missing code - IdP likely rejected the auth request', {
155-
error: errParam,
156-
error_description: errDesc,
157-
});
160+
logger.warn(
161+
'[solidOpenIdDynamic] Callback missing code - IdP likely rejected the auth request',
162+
{
163+
error: errParam,
164+
error_description: errDesc,
165+
},
166+
);
158167
res.redirect(`${process.env.DOMAIN_CLIENT}/login?redirect=false&error=auth_failed`);
159168
return;
160169
}
@@ -190,19 +199,12 @@ async function handleSolidOpenIdCallback(req, res, next) {
190199
discoveryOptions,
191200
);
192201

193-
const currentUrl = new URL(
194-
req.originalUrl || req.url,
195-
process.env.DOMAIN_SERVER,
196-
);
202+
const currentUrl = new URL(req.originalUrl || req.url, process.env.DOMAIN_SERVER);
197203

198-
const tokenset = await client.authorizationCodeGrant(
199-
config,
200-
currentUrl,
201-
{
202-
expectedState: state,
203-
...(sessionData.code_verifier && { pkceCodeVerifier: sessionData.code_verifier }),
204-
},
205-
);
204+
const tokenset = await client.authorizationCodeGrant(config, currentUrl, {
205+
expectedState: state,
206+
...(sessionData.code_verifier && { pkceCodeVerifier: sessionData.code_verifier }),
207+
});
206208

207209
delete req.session[SESSION_KEY][state];
208210
req.session.save(() => {});

api/server/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ const startServer = async () => {
168168
// Local CSS (and other Solid IdPs) fetch this URL to get redirect_uris; they must match the redirect_uri we send in the auth request.
169169
app.get('/solid-client-id', (_, res) => {
170170
const callbackPath =
171-
process.env.SOLID_OPENID_CALLBACK_URL || process.env.OPENID_CALLBACK_URL || '/oauth/openid/callback';
171+
process.env.SOLID_OPENID_CALLBACK_URL ||
172+
process.env.OPENID_CALLBACK_URL ||
173+
'/oauth/openid/callback';
172174
const baseUrl = process.env.DOMAIN_SERVER || 'http://localhost:3080';
173175
const clientId = `${baseUrl}/solid-client-id`;
174176
res.set('Content-Type', 'application/ld+json');

api/server/routes/config.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,7 @@ router.get('/', async function (req, res) {
9696
? [
9797
...DEFAULT_ISSUER_OPTIONS,
9898
...getSolidOpenIdProviders()
99-
.filter(
100-
(p) =>
101-
!DEFAULT_ISSUER_OPTIONS.some(
102-
(d) => normalizeIssuer(d.issuer) === p.issuer,
103-
),
104-
)
99+
.filter((p) => !DEFAULT_ISSUER_OPTIONS.some((d) => normalizeIssuer(d.issuer) === p.issuer))
105100
.map((p) => ({ issuer: p.issuer, label: p.label })),
106101
]
107102
: [],

api/server/services/Config/solidOpenId.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
*/
55

66
const defaultScope = process.env.SOLID_OPENID_SCOPE || 'openid webid offline_access';
7-
const defaultCallbackPath =
8-
process.env.SOLID_OPENID_CALLBACK_URL || '/oauth/openid/callback';
7+
const defaultCallbackPath = process.env.SOLID_OPENID_CALLBACK_URL || '/oauth/openid/callback';
98

109
/**
1110
* Default display labels for known issuers (used when provider config has no label).
@@ -88,7 +87,7 @@ function getSolidOpenIdProviders() {
8887
callbackPath: (p.callbackPath && String(p.callbackPath).trim()) || defaultCallbackPath,
8988
});
9089
}
91-
} catch (e) {
90+
} catch (_e) {
9291
// Invalid JSON
9392
}
9493
}
@@ -154,16 +153,16 @@ function getSolidOpenIdProviderByIssuer(issuer) {
154153
if (configured) return configured;
155154

156155
// Custom issuer: use SOLID_OPENID_CUSTOM_* if set and URL is allowed
157-
if (
158-
process.env.SOLID_OPENID_CUSTOM_CLIENT_ID &&
159-
isAllowedCustomIssuer(normalized)
160-
) {
156+
if (process.env.SOLID_OPENID_CUSTOM_CLIENT_ID && isAllowedCustomIssuer(normalized)) {
161157
return {
162158
issuer: normalized,
163159
clientId: process.env.SOLID_OPENID_CUSTOM_CLIENT_ID,
164160
clientSecret: process.env.SOLID_OPENID_CUSTOM_CLIENT_SECRET || '',
165161
scope: process.env.SOLID_OPENID_CUSTOM_SCOPE || defaultScope,
166-
label: KNOWN_ISSUER_LABELS[normalized] || KNOWN_ISSUER_LABELS[normalized.replace(/\/$/, '')] || 'Custom',
162+
label:
163+
KNOWN_ISSUER_LABELS[normalized] ||
164+
KNOWN_ISSUER_LABELS[normalized.replace(/\/$/, '')] ||
165+
'Custom',
167166
callbackPath: defaultCallbackPath,
168167
};
169168
}

api/server/socialLogins.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ const {
1515
setupSaml,
1616
} = require('~/strategies');
1717
const { getLogStores } = require('~/cache');
18-
const { getSolidOpenIdProviders, getSolidOpenIdProvidersForJwt, isSolidOpenIdEnabled } = require('./services/Config/solidOpenId');
18+
const {
19+
getSolidOpenIdProviders,
20+
getSolidOpenIdProvidersForJwt,
21+
isSolidOpenIdEnabled,
22+
} = require('./services/Config/solidOpenId');
1923
const { ensureSolidJwtRegistered } = require('./services/ensureSolidJwt');
2024

2125
/**
@@ -74,7 +78,9 @@ async function configureSolidOpenIdFromProviders(app) {
7478

7579
const config = await setupSolidOpenIdFromProvider(providers[0]);
7680
if (!config) {
77-
logger.warn('[configureSolidOpenIdFromProviders] Discovery for first provider failed - solidJwt not registered.');
81+
logger.warn(
82+
'[configureSolidOpenIdFromProviders] Discovery for first provider failed - solidJwt not registered.',
83+
);
7884
return;
7985
}
8086
passport.use('solidJwt', openIdJwtLogin(config));
@@ -142,11 +148,7 @@ const configureSocialLogins = async (app) => {
142148
}
143149
// Solid: dynamic providers only (SOLID_OPENID_PROVIDERS or SOLID_OPENID_CUSTOM_CLIENT_ID). Session + solidJwt from first provider.
144150
const solidProvidersForJwt = getSolidOpenIdProvidersForJwt();
145-
const solidProvidersFromEnv = getSolidOpenIdProviders();
146-
if (
147-
process.env.SOLID_OPENID_SESSION_SECRET &&
148-
solidProvidersForJwt.length > 0
149-
) {
151+
if (process.env.SOLID_OPENID_SESSION_SECRET && solidProvidersForJwt.length > 0) {
150152
await configureSolidOpenIdFromProviders(app);
151153
} else if (solidProvidersForJwt.length > 0) {
152154
await registerSolidJwtFromProviders();

api/strategies/SolidOpenidStrategy.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ async function verifySolidUser(tokenset, openidConfig) {
496496
* @function setupSolidOpenId
497497
* @returns {Promise<Configuration | null>}
498498
*/
499-
async function setupSolidOpenId() {
499+
async function _setupSolidOpenId() {
500500
try {
501501
const shouldGenerateNonce = isEnabled(process.env.OPENID_GENERATE_NONCE);
502502

@@ -524,9 +524,9 @@ async function setupSolidOpenId() {
524524
},
525525
);
526526

527-
const requiredRole = process.env.OPENID_REQUIRED_ROLE;
528-
const requiredRoleParameterPath = process.env.OPENID_REQUIRED_ROLE_PARAMETER_PATH;
529-
const requiredRoleTokenKind = process.env.OPENID_REQUIRED_ROLE_TOKEN_KIND;
527+
const _requiredRole = process.env.OPENID_REQUIRED_ROLE;
528+
const _requiredRoleParameterPath = process.env.OPENID_REQUIRED_ROLE_PARAMETER_PATH;
529+
const _requiredRoleTokenKind = process.env.OPENID_REQUIRED_ROLE_TOKEN_KIND;
530530
const usePKCE = isEnabled(process.env.OPENID_USE_PKCE);
531531
logger.info(`[SolidOpenidStrategy] OpenID authentication configuration`, {
532532
generateNonce: shouldGenerateNonce,
@@ -537,9 +537,9 @@ async function setupSolidOpenId() {
537537

538538
// Set of env variables that specify how to set if a user is an admin
539539
// If not set, all users will be treated as regular users
540-
const adminRole = process.env.OPENID_ADMIN_ROLE;
541-
const adminRoleParameterPath = process.env.OPENID_ADMIN_ROLE_PARAMETER_PATH;
542-
const adminRoleTokenKind = process.env.OPENID_ADMIN_ROLE_TOKEN_KIND;
540+
const _adminRole = process.env.OPENID_ADMIN_ROLE;
541+
const _adminRoleParameterPath = process.env.OPENID_ADMIN_ROLE_PARAMETER_PATH;
542+
const _adminRoleTokenKind = process.env.OPENID_ADMIN_ROLE_TOKEN_KIND;
543543

544544
const openidLogin = new CustomOpenIDStrategy(
545545
{

client/src/components/Auth/SolidLoginButton.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
} from '@librechat/client';
1313
import type { TStartupConfig } from 'librechat-data-provider';
1414

15+
import { useLocalize, TranslationKeys } from '~/hooks';
16+
1517
type SolidLoginButtonProps = {
1618
startupConfig: TStartupConfig;
1719
label: string;
@@ -34,6 +36,7 @@ function isValidIssuerUrl(url: string): boolean {
3436
* Redirects to serverDomain + '/oauth/openid?issuer=' + encodeURIComponent(selectedIssuer)
3537
*/
3638
function SolidLoginButton({ startupConfig, label, Icon }: SolidLoginButtonProps) {
39+
const localize = useLocalize();
3740
const [open, setOpen] = useState(false);
3841
const [providerUrl, setProviderUrl] = useState('');
3942
const [selectedOptionIssuer, setSelectedOptionIssuer] = useState<string | null>(null);
@@ -47,7 +50,9 @@ function SolidLoginButton({ startupConfig, label, Icon }: SolidLoginButtonProps)
4750
const canContinue =
4851
serverDomain &&
4952
!!trimmedUrl &&
50-
(customEnabled ? isValidIssuerUrl(trimmedUrl) : options.some((opt) => opt.issuer === trimmedUrl));
53+
(customEnabled
54+
? isValidIssuerUrl(trimmedUrl)
55+
: options.some((opt) => opt.issuer === trimmedUrl));
5156

5257
const handleSelectOption = (issuer: string) => {
5358
setSelectedOptionIssuer(issuer);
@@ -88,23 +93,22 @@ function SolidLoginButton({ startupConfig, label, Icon }: SolidLoginButtonProps)
8893
</OGDialogTrigger>
8994
<OGDialogContent className="max-w-md">
9095
<OGDialogHeader>
91-
<OGDialogTitle>Choose Solid Identity Provider</OGDialogTitle>
96+
<OGDialogTitle>
97+
{localize('com_auth_solid_idp_modal_title' as TranslationKeys)}
98+
</OGDialogTitle>
9299
<OGDialogDescription>
93-
Enter your provider URL or pick one of the providers below.
100+
{localize('com_auth_solid_idp_modal_description' as TranslationKeys)}
94101
</OGDialogDescription>
95102
</OGDialogHeader>
96103
<div className="space-y-4 py-4">
97104
<div className="space-y-2">
98-
<label
99-
htmlFor="solid-idp-url"
100-
className="text-sm font-medium text-text-primary"
101-
>
102-
Solid Identity Provider
105+
<label htmlFor="solid-idp-url" className="text-sm font-medium text-text-primary">
106+
{localize('com_auth_solid_idp_label' as TranslationKeys)}
103107
</label>
104108
<input
105109
id="solid-idp-url"
106110
type="url"
107-
placeholder="Enter your provider URL"
111+
placeholder={localize('com_auth_solid_idp_placeholder' as TranslationKeys)}
108112
value={providerUrl}
109113
onChange={(e) => {
110114
setProviderUrl(e.target.value);
@@ -120,7 +124,7 @@ function SolidLoginButton({ startupConfig, label, Icon }: SolidLoginButtonProps)
120124
{options.length > 0 && (
121125
<div className="space-y-2">
122126
<p className="text-sm font-medium text-text-secondary">
123-
Or select a provider:
127+
{localize('com_auth_solid_select_provider' as TranslationKeys)}
124128
</p>
125129
<div className="flex flex-wrap gap-2">
126130
{options.map((opt) => {
@@ -146,10 +150,10 @@ function SolidLoginButton({ startupConfig, label, Icon }: SolidLoginButtonProps)
146150
</div>
147151
<OGDialogFooter>
148152
<OGDialogClose asChild>
149-
<Button variant="outline">Cancel</Button>
153+
<Button variant="outline">{localize('com_ui_cancel' as TranslationKeys)}</Button>
150154
</OGDialogClose>
151155
<Button onClick={handleContinue} disabled={!canContinue}>
152-
Continue
156+
{localize('com_auth_continue' as TranslationKeys)}
153157
</Button>
154158
</OGDialogFooter>
155159
</OGDialogContent>

client/src/locales/en/translation.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
"com_auth_click": "Click",
153153
"com_auth_click_here": "Click here",
154154
"com_auth_continue": "Continue",
155+
"com_auth_solid_idp_modal_description": "Enter your provider URL or pick one of the providers below.",
156+
"com_auth_solid_idp_modal_title": "Choose Solid Identity Provider",
157+
"com_auth_solid_idp_placeholder": "Enter your provider URL",
158+
"com_auth_solid_idp_label": "Solid Identity Provider",
159+
"com_auth_solid_select_provider": "Or select a provider:",
155160
"com_auth_create_account": "Create your account",
156161
"com_auth_discord_login": "Continue with Discord",
157162
"com_auth_email": "Email",

0 commit comments

Comments
 (0)