javascript-solid-server 0.0.142 → 0.0.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/idp/index.js +1 -1
- package/src/idp/views.js +13 -6
- package/test/idp.test.js +53 -0
package/package.json
CHANGED
package/src/idp/index.js
CHANGED
|
@@ -183,7 +183,7 @@ export async function idpPlugin(fastify, options) {
|
|
|
183
183
|
// Pairs with the /idp/auth guard above so a human visitor lands here
|
|
184
184
|
// rather than on a raw OIDC error.
|
|
185
185
|
fastify.get('/idp', async (request, reply) => {
|
|
186
|
-
return reply.type('text/html').send(landingPage({ baseUri: issuer }));
|
|
186
|
+
return reply.type('text/html').send(landingPage({ baseUri: issuer, singleUser }));
|
|
187
187
|
});
|
|
188
188
|
|
|
189
189
|
// Token sub-paths
|
package/src/idp/views.js
CHANGED
|
@@ -555,12 +555,15 @@ export function errorPage(title, message) {
|
|
|
555
555
|
*
|
|
556
556
|
* The OIDC authorization endpoint (/idp/auth) requires a client_id; opening
|
|
557
557
|
* /idp manually used to drop the user into a raw OIDC error. This page is
|
|
558
|
-
* the human-navigable entry point
|
|
559
|
-
*
|
|
560
|
-
*
|
|
558
|
+
* the human-navigable entry point.
|
|
559
|
+
*
|
|
560
|
+
* In single-user mode (`ctx.singleUser`) the Create Account button is
|
|
561
|
+
* suppressed — pod creation is disabled and the button would lead to a
|
|
562
|
+
* 403. The sign-in note still names pilot as the example client.
|
|
561
563
|
*/
|
|
562
564
|
export function landingPage(ctx = {}) {
|
|
563
565
|
const issuer = ctx.baseUri || '';
|
|
566
|
+
const singleUser = !!ctx.singleUser;
|
|
564
567
|
return `
|
|
565
568
|
<!DOCTYPE html>
|
|
566
569
|
<html lang="en">
|
|
@@ -607,13 +610,17 @@ export function landingPage(ctx = {}) {
|
|
|
607
610
|
<div class="container landing">
|
|
608
611
|
<div class="landing-header">
|
|
609
612
|
<h1>Solid Pod Server</h1>
|
|
610
|
-
<p class="subtitle"
|
|
613
|
+
<p class="subtitle">${singleUser
|
|
614
|
+
? 'Single-user pod — sign in from any Solid app.'
|
|
615
|
+
: 'Create an account, then sign in from any Solid app.'}</p>
|
|
611
616
|
</div>
|
|
612
617
|
|
|
613
|
-
|
|
618
|
+
${singleUser
|
|
619
|
+
? '' /* Registration is disabled in single-user mode; suppress the dead-end button. */
|
|
620
|
+
: '<a href="/idp/register" class="btn btn-primary" style="text-decoration: none;">Create Account</a>'}
|
|
614
621
|
|
|
615
622
|
<div class="signin-note">
|
|
616
|
-
<strong
|
|
623
|
+
<strong>${singleUser ? 'Sign in' : 'Already have an account?'}</strong> ${singleUser ? 'from' : 'Sign in from'} a Solid app — for example, <a href="https://solid-apps.github.io/pilot/" target="_blank" rel="noopener">pilot</a> is a minimal console you can open right now. Point it at this server and click Sign In.
|
|
617
624
|
</div>
|
|
618
625
|
|
|
619
626
|
${issuer ? `<div class="issuer">Issuer: ${escapeHtml(issuer.replace(/\/$/, ''))}</div>` : ''}
|
package/test/idp.test.js
CHANGED
|
@@ -356,6 +356,59 @@ describe('Identity Provider - Subdomain mode register validation', () => {
|
|
|
356
356
|
});
|
|
357
357
|
});
|
|
358
358
|
|
|
359
|
+
// Single-user mode: registration is disabled, so the /idp landing must
|
|
360
|
+
// suppress the "Create Account" button rather than ship a known 403 trap.
|
|
361
|
+
// Regression coverage for #290.
|
|
362
|
+
describe('Identity Provider - Single-user mode landing', () => {
|
|
363
|
+
let server;
|
|
364
|
+
let baseUrl;
|
|
365
|
+
const SINGLE_USER_DATA_DIR = './test-data-idp-single-user';
|
|
366
|
+
|
|
367
|
+
before(async () => {
|
|
368
|
+
await fs.remove(SINGLE_USER_DATA_DIR);
|
|
369
|
+
await fs.ensureDir(SINGLE_USER_DATA_DIR);
|
|
370
|
+
|
|
371
|
+
const port = await getAvailablePort();
|
|
372
|
+
baseUrl = `http://${TEST_HOST}:${port}`;
|
|
373
|
+
|
|
374
|
+
server = createServer({
|
|
375
|
+
logger: false,
|
|
376
|
+
root: SINGLE_USER_DATA_DIR,
|
|
377
|
+
idp: true,
|
|
378
|
+
idpIssuer: baseUrl,
|
|
379
|
+
singleUser: true,
|
|
380
|
+
singleUserName: 'me',
|
|
381
|
+
forceCloseConnections: true,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
await server.listen({ port, host: TEST_HOST });
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
after(async () => {
|
|
388
|
+
await server.close();
|
|
389
|
+
await fs.remove(SINGLE_USER_DATA_DIR);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it('GET /idp omits the Create Account button', async () => {
|
|
393
|
+
const res = await fetch(`${baseUrl}/idp`);
|
|
394
|
+
assert.strictEqual(res.status, 200);
|
|
395
|
+
const body = await res.text();
|
|
396
|
+
// Sanity: the landing still rendered.
|
|
397
|
+
assert.match(body, /Solid Pod Server/);
|
|
398
|
+
// Button + register link must be absent — those would 403 in single-user mode.
|
|
399
|
+
assert.doesNotMatch(body, /Create Account/);
|
|
400
|
+
assert.doesNotMatch(body, /href="\/idp\/register"/);
|
|
401
|
+
// Sign-in note should still mention pilot as the example client.
|
|
402
|
+
assert.match(body, /solid-apps\.github\.io\/pilot/);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it('subtitle reflects the single-user shape', async () => {
|
|
406
|
+
const res = await fetch(`${baseUrl}/idp`);
|
|
407
|
+
const body = await res.text();
|
|
408
|
+
assert.match(body, /Single-user pod/);
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
|
|
359
412
|
describe('Identity Provider - Accounts', () => {
|
|
360
413
|
let server;
|
|
361
414
|
let accountsUrl;
|