Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions test/integration/acl-tls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ var rm = require('../utils').rm
var ldnode = require('../../index')
var ns = require('solid-namespace')($rdf)

var address = 'https://localhost:3456/test/'
let rootPath = path.join(__dirname, '../resources')
let configPath = path.join(rootPath, 'config')
const port = 7777
const serverUri = `https://localhost:7777`
const rootPath = path.join(__dirname, '../resources/acl-tls')
const dbPath = path.join(rootPath, 'db')
const configPath = path.join(rootPath, 'config')

var aclExtension = '.acl'
var metaExtension = '.meta'
Expand All @@ -37,8 +39,9 @@ var globFile = testDir + '/*'
var origin1 = 'http://example.org/'
var origin2 = 'http://example.com/'

var user1 = 'https://user1.databox.me/profile/card#me'
var user2 = 'https://user2.databox.me/profile/card#me'
var user1 = 'https://tim.localhost:7777/profile/card#me'
var user2 = 'https://nicola.localhost:7777/profile/card#me'
var address = 'https://tim.localhost:7777'
var userCredentials = {
user1: {
cert: fs.readFileSync(path.join(__dirname, '../keys/user1-cert.pem')),
Expand All @@ -50,22 +53,38 @@ var userCredentials = {
}
}

describe('ACL with WebID+TLS', function () {
// TODO Remove skip. TLS is currently broken, but is not a priority to fix since
// the current Solid spec does not require supporting webid-tls on the resource
// server. The current spec only requires the resource server to support webid-oidc,
// and it requires the IDP to support webid-tls as a log in method, so that users of
// a webid-tls client certificate can still use their certificate (and not a
// username/password pair or other login method) to "bridge" from webid-tls to
// webid-oidc.
describe.skip('ACL with WebID+TLS', function () {
var ldpHttpsServer
var ldp = ldnode.createServer({
mount: '/test',
var serverConfig = {
root: rootPath,
serverUri,
dbPath,
port,
configPath,
sslKey: path.join(__dirname, '../keys/key.pem'),
sslCert: path.join(__dirname, '../keys/cert.pem'),
webid: true,
strictOrigin: true,
multiuser: true,
auth: 'tls',
rejectUnauthorized: false
})
rejectUnauthorized: false,
strictOrigin: true,
host: { serverUri }
}
var ldp = ldnode.createServer(serverConfig)

before(function (done) {
ldpHttpsServer = ldp.listen(3456, done)
ldpHttpsServer = ldp.listen(port, () => {
setTimeout(() => {
done()
}, 0)
})
})

after(function () {
Expand Down Expand Up @@ -466,7 +485,7 @@ describe('ACL with WebID+TLS', function () {
})

describe('Read-only', function () {
var body = fs.readFileSync(path.join(__dirname, '../resources/acl-tls/read-acl/.acl'))
var body = fs.readFileSync(path.join(__dirname, '../resources/acl-tls/tim.localhost/read-acl/.acl'))
it('user1 should be able to access ACL file', function (done) {
var options = createOptions('/acl-tls/read-acl/.acl', 'user1')
request.head(options, function (error, response, body) {
Expand Down
44 changes: 22 additions & 22 deletions test/keys/user1-cert.pem
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
Bag Attributes
friendlyName: user1 [on user1.databox.me]'s WebID ID
localKeyID: 4A 83 02 D8 45 D4 50 5C 29 45 D7 6E 75 41 5A 71 C2 D7 ED 1B
subject=/O=WebID/CN=user1 [on user1.databox.me]
issuer=/O=WebID/CN=user1 [on user1.databox.me]
-----BEGIN CERTIFICATE-----
MIIC6TCCAlSgAwIBAgIBKjALBgkqhkiG9w0BAQswNjEOMAwGA1UEChMFV2ViSUQx
JDAiBgNVBAMMG3VzZXIxIFtvbiB1c2VyMS5kYXRhYm94Lm1lXTAeFw0wMDAxMDEw
MDAwMDBaFw00OTEyMzEyMzU5NTlaMDYxDjAMBgNVBAoTBVdlYklEMSQwIgYDVQQD
DBt1c2VyMSBbb24gdXNlcjEuZGF0YWJveC5tZV0wggEiMA0GCSqGSIb3DQEBAQUA
A4IBDwAwggEKAoIBAQC9prgg9hPV1ICTDJpOphfO46KpDSnsE8L+JI2wp5nIxgAK
WDGfOmjLfJN3JJk90G0Tr8FjrY230XBL8yW7JG9K94NhPzltcP3lbMPRub9CYPP+
z8pMiJdwI3W4gIM9BTWP83p+/DIwL8xVreTGh8hd2BuWCO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Lxzzzl3A6VQ+zCV0SQ17npauEGQzVXg+QhOwRUbH4rfOoT6CrYmcnhrmkiGAqfY
HO2I5DsJAyiLtuTmMPBVkLgDuhs0eOR0jsjbBE1AJ809i4Nngu5vYSNhf3rZz/qU
ZEvvWDnb50EQJrAGeWndNl/+EohENPKlpFmBedgttwJGc/skuNpAwBta+F03EdO8
6V2Z+qDQKdyG1VvXVF5SVB9jPOXkWLQrTTyjcyyE8Sx62ZXxDlsYvQAGd27Iuw4E
emmST8jxvjob8mC5Pb1KAhAK7EIbMIUAP456TwIDAQABo4GPMIGMMB0GA1UdDgQW
BBSKeuVdr8beU5Y6NkeggCSCtlZZrDA4BgNVHREBAf8ELjAshipodHRwczovL3Rp
bS5sb2NhbGhvc3Q6Nzc3Ny9wcm9maWxlL2NhcmQjbWUwCQYDVR0TBAIwADATBgNV
HSUEDDAKBggrBgEFBQcDAjARBglghkgBhvhCAQEEBAMCB4AwDQYJKoZIhvcNAQEF
BQADggEBACH7beIj0OFsq6FwkthagI53cxPhjIxFOYdy8G5mN/JcCyL0xemJm5Fz
HEXKv/QhFdbX6NCCal/d+2r566fRf1C/8sY/Cx4yKqYaZ/ZZeH/q3IlfQSyEZEJy
XLARCG9WzeXHJsL6u/lN/rcrI3ylUb9qAAzlNWyg3xtb58ieUSUjuO0fOfKMu+LJ
VGPpMyhtjwBhelJ32l6ffHpnyzj6v14QxTEGWQpLvtX1iUDExNbHcm8khlbEgGzG
Zyrojk0cHg3tH4nmBei7QvuLOiDaBs2N5ITTETwExiWD2CUPCiYO0DMr0oljN/nS
KRRJsj1QOjM4/A46RjXWhmvx7RTXQdM=
-----END CERTIFICATE-----
55 changes: 28 additions & 27 deletions test/keys/user1-key.pem
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvaa4IPYT1dSAkwyaTqYXzuOiqQ0p7BPC/iSNsKeZyMYAClgx
nzpoy3yTdySZPdBtE6/BY62Nt9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EY-----
49 changes: 49 additions & 0 deletions test/resources/acl-tls/config/templates/emails/delete-account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict'

/**
* Returns a partial Email object (minus the `to` and `from` properties),
* suitable for sending with Nodemailer.
*
* Used to send a Delete Account email, upon user request
*
* @param data {Object}
*
* @param data.deleteUrl {string}
* @param data.webId {string}
*
* @return {Object}
*/
function render (data) {
return {
subject: 'Delete Solid-account request',

/**
* Text version
*/
text: `Hi,

We received a request to delete your Solid account, ${data.webId}

To delete your account, click on the following link:

${data.deleteUrl}

If you did not mean to delete your account, ignore this email.`,

/**
* HTML version
*/
html: `<p>Hi,</p>

<p>We received a request to delete your Solid account, ${data.webId}</p>

<p>To delete your account, click on the following link:</p>

<p><a href="${data.deleteUrl}">${data.deleteUrl}</a></p>

<p>If you did not mean to delete your account, ignore this email.</p>
`
}
}

module.exports.render = render
30 changes: 30 additions & 0 deletions test/resources/acl-tls/config/templates/emails/invalid-username.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports.render = render

function render (data) {
return {
subject: `Invalid username for account ${data.accountUri}`,

/**
* Text version
*/
text: `Hi,

We're sorry to inform you that the username for account ${data.accountUri} is not allowed after changes to username policy.

This account has been set to be deleted at ${data.dateOfRemoval}.

${data.supportEmail ? `Please contact ${data.supportEmail} if you want to move your account.` : ''}`,

/**
* HTML version
*/
html: `<p>Hi,</p>

<p>We're sorry to inform you that the username for account ${data.accountUri} is not allowed after changes to username policy.</p>

<p>This account has been set to be deleted at ${data.dateOfRemoval}.</p>

${data.supportEmail ? `<p>Please contact ${data.supportEmail} if you want to move your account.</p>` : ''}
`
}
}
49 changes: 49 additions & 0 deletions test/resources/acl-tls/config/templates/emails/reset-password.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict'

/**
* Returns a partial Email object (minus the `to` and `from` properties),
* suitable for sending with Nodemailer.
*
* Used to send a Reset Password email, upon user request
*
* @param data {Object}
*
* @param data.resetUrl {string}
* @param data.webId {string}
*
* @return {Object}
*/
function render (data) {
return {
subject: 'Account password reset',

/**
* Text version
*/
text: `Hi,

We received a request to reset your password for your Solid account, ${data.webId}

To reset your password, click on the following link:

${data.resetUrl}

If you did not mean to reset your password, ignore this email, your password will not change.`,

/**
* HTML version
*/
html: `<p>Hi,</p>

<p>We received a request to reset your password for your Solid account, ${data.webId}</p>

<p>To reset your password, click on the following link:</p>

<p><a href="${data.resetUrl}">${data.resetUrl}</a></p>

<p>If you did not mean to reset your password, ignore this email, your password will not change.</p>
`
}
}

module.exports.render = render
39 changes: 39 additions & 0 deletions test/resources/acl-tls/config/templates/emails/welcome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use strict'

/**
* Returns a partial Email object (minus the `to` and `from` properties),
* suitable for sending with Nodemailer.
*
* Used to send a Welcome email after a new user account has been created.
*
* @param data {Object}
*
* @param data.webid {string}
*
* @return {Object}
*/
function render (data) {
return {
subject: 'Welcome to Solid',

/**
* Text version of the Welcome email
*/
text: `Welcome to Solid!

Your account has been created.

Your Web Id: ${data.webid}`,

/**
* HTML version of the Welcome email
*/
html: `<p>Welcome to Solid!</p>

<p>Your account has been created.</p>

<p>Your Web Id: ${data.webid}</p>`
}
}

module.exports.render = render
26 changes: 26 additions & 0 deletions test/resources/acl-tls/config/templates/new-account/.acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Root ACL resource for the user account
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.

# The homepage is readable by the public
<#public>
a acl:Authorization;
acl:agentClass foaf:Agent;
acl:accessTo </>;
acl:mode acl:Read.

# The owner has full access to every resource in their pod.
# Other agents have no access rights,
# unless specifically authorized in other .acl resources.
<#owner>
a acl:Authorization;
acl:agent <{{webId}}>;
# Optional owner email, to be used for account recovery:
{{#if email}}acl:agent <mailto:{{{email}}}>;{{/if}}
# Set the access to the root storage folder itself
acl:accessTo </>;
# All resources will inherit this authorization, by default
acl:default </>;
# The owner has all of the access modes allowed
acl:mode
acl:Read, acl:Write, acl:Control.
5 changes: 5 additions & 0 deletions test/resources/acl-tls/config/templates/new-account/.meta
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Root Meta resource for the user account
# Used to discover the account's WebID URI, given the account URI
<{{webId}}>
<http://www.w3.org/ns/solid/terms#account>
</>.
Loading