Skip to content

Commit

Permalink
Merge defdb32 into 3bb7a32
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenVerborgh committed Jul 23, 2021
2 parents 3bb7a32 + defdb32 commit a1545de
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 33 deletions.
Expand Up @@ -135,7 +135,11 @@ export class RegistrationHandler extends HttpHandler {
if (result.createPod) {
podBaseUrl = podBaseUrl ?? this.identifierGenerator.generate(result.podName!);
try {
await this.podManager.createPod(podBaseUrl, { ...result.data, webId: result.webId! });
await this.podManager.createPod(podBaseUrl, {
...result.data,
podBaseUrl: podBaseUrl.path,
webId: result.webId!,
});
} catch (error: unknown) {
// In case pod creation errors we don't want to keep the account
if (result.register) {
Expand Down
35 changes: 25 additions & 10 deletions templates/identity/email-password/register-response.html.ejs
Expand Up @@ -13,30 +13,45 @@
</header>
<main>
<h1>You are signed up</h1>
<p>
<strong>Welcome to Solid.</strong>
We wish you an exciting experience!
</p>

<% if (createPod) { %>
<h2>Your new pod</h2>
<p>
Your new pod is located at <a href="<%= podBaseUrl %>" class="link"><%= podBaseUrl %></a>.
<br>
You can store your documents and data there.
</p>
<% } %>

<% if (createWebId) { %>
<h2>Your new WebID</h2>
<p>
Your new WebID is <a href="<%= webId %>" class="link"><%= webId %></a>.
<br>
You can use this identifier to interact with Solid pods and apps.
</p>
<% } %>

<% if (register) { %>
<h2>Your new login</h2>
<p>
You can now identify as <a href="<%= webId %>" class="link"><%= webId %></a>
on this server using <em><%= email %></em>.
You can <a href="./login">log in</a>
with your WebID <a href="<%= webId %>" class="link"><%= webId %></a>
on this server via your email address <em><%= email %></em>.
</p>
<% if (!createWebId) { %>
<p>
Make sure you add the triple
You will need to add the triple
<code><%= `<${webId}> <http://www.w3.org/ns/solid/terms#oidcIssuer> <${oidcIssuer}>.`%></code>
to your WebID profile.
to your existing WebID document <em><%= webId %></em>
to indicate that you trust this server as a login provider for your WebID.
</p>
<% } %>
<% } %>
<% if (createPod) { %>
<p>
Your new pod has been created
and can be found at <a href="<%= podBaseUrl %>" class="link"><%= podBaseUrl %></a>.
</p>
<% } %>
</main>
<footer>
<p>
Expand Down
22 changes: 22 additions & 0 deletions templates/pod/README$.md.hbs
@@ -0,0 +1,22 @@
# Welcome to your pod

## A place to store your data
Your pod is a **secure storage space** for your documents and data.
<br>
You can choose to share those with other people and apps.

As the owner of this pod,
identified by <a href="{{webId}}">{{webId}}</a>,
you have access to all of your documents.

## Working with your pod
The easiest way to interact with pods
is through Solid apps.
<br>
For example,
you can open your pod in [Databrowser](https://solid.github.io/mashlib/dist/browse.html?uri={{podBaseUrl}}).

## Learn more
The [Solid website](https://solidproject.org/)
and the people on its [forum](https://forum.solidproject.org/)
will be glad to help you on your journey.
12 changes: 12 additions & 0 deletions templates/pod/README.acl.hbs
@@ -0,0 +1,12 @@
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.

<#public>
acl:accessTo <./README>;
acl:agentClass foaf:Agent;
acl:mode acl:Read.

<#owner>
acl:accessTo <./README>;
acl:agent <{{webId}}>;
acl:mode acl:Read, acl:Write, acl:Control.
24 changes: 7 additions & 17 deletions test/integration/Identity.test.ts
Expand Up @@ -117,11 +117,9 @@ describe('A Solid server with IDP', (): void => {
const res = await postForm(`${baseUrl}idp/register`, formBody);
expect(res.status).toBe(200);
const text = await res.text();
expect(text).toMatch(new RegExp(`You can now identify as .*${webId}`, 'u'));
expect(text).toMatch(new RegExp(`on this server using <em>${email}</em>`, 'u'));
expect(text).toMatch(new RegExp(`Make sure you add the triple
\\s*<code>&lt;${webId}&gt; &lt;http://www.w3.org/ns/solid/terms#oidcIssuer&gt; &lt;${baseUrl}&gt;\\.</code>
\\s*to your WebID profile\\.`, 'mu'));
expect(text).toMatch(new RegExp(`your WebID.*${webId}`, 'u'));
expect(text).toMatch(new RegExp(`your email address.*${email}`, 'u'));
expect(text).toMatch(new RegExp(`<code>&lt;${webId}&gt; &lt;http://www.w3.org/ns/solid/terms#oidcIssuer&gt; &lt;${baseUrl}&gt;\\.</code>`, 'mu'));
});
});

Expand Down Expand Up @@ -282,16 +280,14 @@ describe('A Solid server with IDP', (): void => {
const res = await postForm(`${baseUrl}idp/register`, formBody);
expect(res.status).toBe(200);
const text = await res.text();
expect(text).toMatch(new RegExp(`Your new pod has been created
\\s*and can be found at.*${baseUrl}${podName}/`, 'u'));
expect(text).toMatch(new RegExp(`Your new pod.*${baseUrl}${podName}/`, 'u'));
});
});

describe('creating a new WebID', (): void => {
const podName = 'alice';
const newMail = 'alice@test.email';
let newWebId: string;
let podLocation: string;
let state: IdentityTestState;

const formBody = stringify({
Expand All @@ -307,15 +303,9 @@ describe('A Solid server with IDP', (): void => {
expect(matchWebId).toBeDefined();
expect(matchWebId).toHaveLength(2);
newWebId = matchWebId![1];
expect(text).toMatch(new RegExp(`You can now identify as .*${newWebId}`, 'u'));
expect(text).toMatch(new RegExp(`on this server using <em>${newMail}</em>.`, 'u'));

const matchPod = /Your new pod has been created\n\s*and can be found at [^>]+>([^<]+)/u.exec(text);
expect(matchPod).toBeDefined();
expect(matchPod).toHaveLength(2);
podLocation = matchPod![1];
expect(newWebId.startsWith(podLocation)).toBe(true);
expect(podLocation.startsWith(baseUrl)).toBe(true);
expect(text).toMatch(new RegExp(`new WebID is.*${newWebId}`, 'u'));
expect(text).toMatch(new RegExp(`your email address.*${newMail}`, 'u'));
expect(text).toMatch(new RegExp(`Your new pod.*${baseUrl}${podName}/`, 'u'));
});

it('initializes the session and logs in.', async(): Promise<void> => {
Expand Down
Expand Up @@ -20,6 +20,7 @@ describe('A RegistrationHandler', (): void => {
const password = 'superSecretPassword';
const confirmPassword = password;
const podName = 'alice';
const podBaseUrl = 'http://test.com/alice/';
// Strings instead of booleans because this is form data
const createWebId = 'true';
const register = 'true';
Expand Down Expand Up @@ -178,7 +179,9 @@ describe('A RegistrationHandler', (): void => {
expect(identifierGenerator.generate).toHaveBeenCalledTimes(1);
expect(identifierGenerator.generate).toHaveBeenLastCalledWith(podName);
expect(podManager.createPod).toHaveBeenCalledTimes(1);
expect(podManager.createPod).toHaveBeenLastCalledWith({ path: `${baseUrl}${podName}/` }, params);
expect(podManager.createPod).toHaveBeenLastCalledWith(
{ path: `${baseUrl}${podName}/` }, { podBaseUrl, ...params },
);

expect(accountStore.create).toHaveBeenCalledTimes(0);
expect(accountStore.verify).toHaveBeenCalledTimes(0);
Expand All @@ -198,7 +201,9 @@ describe('A RegistrationHandler', (): void => {
expect(identifierGenerator.generate).toHaveBeenLastCalledWith(podName);
(params as any).oidcIssuer = baseUrl;
expect(podManager.createPod).toHaveBeenCalledTimes(1);
expect(podManager.createPod).toHaveBeenLastCalledWith({ path: `${baseUrl}${podName}/` }, params);
expect(podManager.createPod).toHaveBeenLastCalledWith(
{ path: `${baseUrl}${podName}/` }, { podBaseUrl, ...params },
);
expect(accountStore.verify).toHaveBeenCalledTimes(1);
expect(accountStore.verify).toHaveBeenLastCalledWith(email);

Expand All @@ -219,7 +224,9 @@ describe('A RegistrationHandler', (): void => {
expect(identifierGenerator.generate).toHaveBeenLastCalledWith(podName);
(params as any).oidcIssuer = baseUrl;
expect(podManager.createPod).toHaveBeenCalledTimes(1);
expect(podManager.createPod).toHaveBeenLastCalledWith({ path: `${baseUrl}${podName}/` }, params);
expect(podManager.createPod).toHaveBeenLastCalledWith(
{ path: `${baseUrl}${podName}/` }, { podBaseUrl, ...params },
);
expect(accountStore.deleteAccount).toHaveBeenCalledTimes(1);
expect(accountStore.deleteAccount).toHaveBeenLastCalledWith(email);

Expand All @@ -239,9 +246,10 @@ describe('A RegistrationHandler', (): void => {
expect(accountStore.create).toHaveBeenLastCalledWith(email, generatedWebID, password);
expect(accountStore.verify).toHaveBeenCalledTimes(1);
expect(accountStore.verify).toHaveBeenLastCalledWith(email);
const podParams = { ...params, oidcIssuer: baseUrl, webId: generatedWebID };
expect(podManager.createPod).toHaveBeenCalledTimes(1);
expect(podManager.createPod).toHaveBeenLastCalledWith({ path: `${baseUrl}${podName}/` }, podParams);
expect(podManager.createPod).toHaveBeenLastCalledWith(
{ path: `${baseUrl}${podName}/` }, { ...params, podBaseUrl, oidcIssuer: baseUrl, webId: generatedWebID },
);

expect(ownershipValidator.handleSafe).toHaveBeenCalledTimes(0);
expect(accountStore.deleteAccount).toHaveBeenCalledTimes(0);
Expand Down

0 comments on commit a1545de

Please sign in to comment.