solid-server 5.8.6 → 5.8.8-22f4cfec
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/CHANGELOG.md +0 -0
- package/CONTRIBUTING.md +0 -0
- package/CONTRIBUTORS.md +0 -0
- package/Dockerfile +0 -0
- package/LICENSE.md +0 -0
- package/README.md +0 -0
- package/bin/config.json +0 -0
- package/bin/lib/cli-utils.mjs +54 -0
- package/bin/lib/cli.mjs +44 -0
- package/bin/lib/{init.js → init.mjs} +93 -94
- package/bin/lib/{invalidUsernames.js → invalidUsernames.mjs} +136 -148
- package/bin/lib/{migrateLegacyResources.js → migrateLegacyResources.mjs} +64 -69
- package/bin/lib/{options.js → options.mjs} +379 -405
- package/bin/lib/{start.js → start.mjs} +124 -148
- package/bin/lib/{updateIndex.js → updateIndex.mjs} +55 -56
- package/bin/solid +2 -2
- package/bin/solid-test +0 -0
- package/common/css/bootstrap.min.css +6 -0
- package/common/css/solid.css +0 -0
- package/common/fonts/glyphicons-halflings-regular.eot +0 -0
- package/common/fonts/glyphicons-halflings-regular.svg +0 -0
- package/common/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/common/fonts/glyphicons-halflings-regular.woff +0 -0
- package/common/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/common/img/solid-emblem.svg +0 -0
- package/common/js/auth-buttons.js +0 -0
- package/common/js/auth-buttons.mjs +57 -0
- package/common/js/index-buttons.js +0 -0
- package/common/js/index-buttons.mjs +43 -0
- package/common/js/solid.js +0 -0
- package/common/js/solid.mjs +456 -0
- package/common/well-known/security.txt +0 -0
- package/config/defaults.js +0 -0
- package/config/defaults.mjs +22 -0
- package/config/templates/emails/delete-account.js +49 -0
- package/config/templates/emails/delete-account.mjs +31 -0
- package/config/templates/emails/invalid-username.js +30 -0
- package/config/templates/emails/invalid-username.mjs +27 -0
- package/config/templates/emails/reset-password.js +49 -0
- package/config/templates/emails/reset-password.mjs +31 -0
- package/config/templates/emails/welcome.js +39 -0
- package/config/templates/emails/welcome.mjs +23 -0
- package/config/templates/new-account/favicon.ico +0 -0
- package/config/templates/new-account/favicon.ico.acl +26 -0
- package/config/templates/new-account/profile/card$.ttl +26 -0
- package/config/templates/new-account/robots.txt +3 -0
- package/config/templates/new-account/robots.txt.acl +26 -0
- package/config/templates/new-account/settings/prefs.ttl +15 -0
- package/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/{default-templates/new-account/.meta.acl → config/templates/new-account/settings/publicTypeIndex.ttl.acl} +4 -4
- package/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/config/templates/server/favicon.ico +0 -0
- package/{.well-known/.acl → config/templates/server/favicon.ico.acl} +2 -2
- package/config/templates/server/index.html +54 -0
- package/config/templates/server/robots.txt +3 -0
- package/{default-templates/server/.well-known/.acl → config/templates/server/robots.txt.acl} +2 -2
- package/config/usernames-blacklist.json +0 -0
- package/config/views/account/account-deleted.hbs +17 -0
- package/config/views/account/delete-confirm.hbs +51 -0
- package/config/views/account/delete-link-sent.hbs +17 -0
- package/config/views/account/delete.hbs +51 -0
- package/config/views/account/invalid-username.hbs +22 -0
- package/config/views/account/register-disabled.hbs +6 -0
- package/config/views/account/register-form.hbs +133 -0
- package/config/views/account/register.hbs +24 -0
- package/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/config/views/auth/change-password.hbs +58 -0
- package/config/views/auth/goodbye.hbs +23 -0
- package/config/views/auth/login-required.hbs +34 -0
- package/config/views/auth/login-tls.hbs +11 -0
- package/config/views/auth/login-username-password.hbs +28 -0
- package/config/views/auth/login.hbs +55 -0
- package/config/views/auth/no-permission.hbs +29 -0
- package/config/views/auth/password-changed.hbs +27 -0
- package/config/views/auth/reset-link-sent.hbs +21 -0
- package/config/views/auth/reset-password.hbs +52 -0
- package/config/views/auth/sharing.hbs +49 -0
- package/config/views/shared/create-account.hbs +8 -0
- package/config/views/shared/error.hbs +5 -0
- package/config.json-default +0 -0
- package/coverage/tmp/coverage-2260-1766832656715-0.json +1 -0
- package/coverage/tmp/coverage-2261-1766832635310-0.json +1 -0
- package/default-templates/emails/delete-account.js +0 -0
- package/default-templates/emails/delete-account.mjs +31 -0
- package/default-templates/emails/invalid-username.js +0 -0
- package/default-templates/emails/invalid-username.mjs +27 -0
- package/default-templates/emails/reset-password.js +0 -0
- package/default-templates/emails/reset-password.mjs +31 -0
- package/default-templates/emails/welcome.js +0 -0
- package/default-templates/emails/welcome.mjs +23 -0
- package/default-templates/new-account/favicon.ico +0 -0
- package/default-templates/new-account/favicon.ico.acl +0 -0
- package/default-templates/new-account/profile/card$.ttl +0 -0
- package/default-templates/new-account/robots.txt +0 -0
- package/default-templates/new-account/robots.txt.acl +0 -0
- package/default-templates/new-account/settings/prefs.ttl +0 -0
- package/default-templates/new-account/settings/privateTypeIndex.ttl +0 -0
- package/default-templates/new-account/settings/publicTypeIndex.ttl +0 -0
- package/default-templates/new-account/settings/publicTypeIndex.ttl.acl +0 -0
- package/default-templates/new-account/settings/serverSide.ttl.acl +0 -0
- package/default-templates/new-account/settings/serverSide.ttl.inactive +0 -0
- package/default-templates/server/favicon.ico +0 -0
- package/default-templates/server/favicon.ico.acl +0 -0
- package/default-templates/server/index.html +0 -0
- package/default-templates/server/robots.txt +0 -0
- package/default-templates/server/robots.txt.acl +0 -0
- package/default-views/account/account-deleted.hbs +0 -0
- package/default-views/account/delete-confirm.hbs +0 -0
- package/default-views/account/delete-link-sent.hbs +0 -0
- package/default-views/account/delete.hbs +0 -0
- package/default-views/account/invalid-username.hbs +0 -0
- package/default-views/account/register-disabled.hbs +0 -0
- package/default-views/account/register-form.hbs +0 -0
- package/default-views/account/register.hbs +0 -0
- package/default-views/auth/auth-hidden-fields.hbs +0 -0
- package/default-views/auth/change-password.hbs +0 -0
- package/default-views/auth/goodbye.hbs +0 -0
- package/default-views/auth/login-required.hbs +0 -0
- package/default-views/auth/login-tls.hbs +0 -0
- package/default-views/auth/login-username-password.hbs +0 -0
- package/default-views/auth/login.hbs +0 -0
- package/default-views/auth/no-permission.hbs +0 -0
- package/default-views/auth/password-changed.hbs +0 -0
- package/default-views/auth/reset-link-sent.hbs +0 -0
- package/default-views/auth/reset-password.hbs +0 -0
- package/default-views/auth/sharing.hbs +0 -0
- package/default-views/shared/create-account.hbs +0 -0
- package/default-views/shared/error.hbs +0 -0
- package/docker-compose.yml +0 -0
- package/docker-image/CONTRIBUTING.md +33 -0
- package/docker-image/Makefile +32 -0
- package/docker-image/README.md +65 -0
- package/docker-image/examples/docker-compose.all-in-one.yml +76 -0
- package/docker-image/examples/docker-compose.nginx.yml +51 -0
- package/docker-image/examples/docker-compose.simple.yml +34 -0
- package/docker-image/src/Dockerfile +34 -0
- package/docker-image/src/checks.sh +56 -0
- package/docker-image/src/create-temporary-cert.sh +14 -0
- package/docker-image/src/entrypoint.sh +8 -0
- package/{common/img/.gitkeep → docker-image/test/__init__.py} +0 -0
- package/docker-image/test/conftest.py +15 -0
- package/docker-image/test/test_image_foundations.py +51 -0
- package/docker-image/test/test_non_accessible_key_cert.py +36 -0
- package/docker-image/test/test_precondition_checks.py +41 -0
- package/docker-image/test/test_solid_default_config.py +66 -0
- package/docker-image/test/test_volumes.py +55 -0
- package/docker-image/test/wait_for_container.py +8 -0
- package/docs/how-to-delete-your-account.md +0 -0
- package/docs/login-and-grant-access-to-application.md +0 -0
- package/examples/custom-error-handling.js +0 -0
- package/examples/custom-error-handling.mjs +29 -0
- package/examples/ldp-with-webid.js +0 -0
- package/examples/ldp-with-webid.mjs +12 -0
- package/examples/simple-express-app.js +0 -0
- package/examples/simple-express-app.mjs +20 -0
- package/examples/simple-ldp-server.js +0 -0
- package/examples/simple-ldp-server.mjs +8 -0
- package/favicon.ico +0 -0
- package/favicon.ico.acl +0 -0
- package/index.cjs +4 -0
- package/index.html +0 -0
- package/index.mjs +23 -0
- package/lib/{acl-checker.js → acl-checker.mjs} +13 -15
- package/lib/api/accounts/{user-accounts.js → user-accounts.mjs} +17 -16
- package/lib/api/authn/{force-user.js → force-user.mjs} +5 -4
- package/lib/api/authn/index.mjs +8 -0
- package/lib/api/authn/{webid-oidc.js → webid-oidc.mjs} +27 -20
- package/lib/api/authn/{webid-tls.js → webid-tls.mjs} +12 -11
- package/lib/api/index.mjs +7 -0
- package/lib/{capability-discovery.js → capability-discovery.mjs} +3 -6
- package/lib/common/{fs-utils.js → fs-utils.mjs} +35 -43
- package/lib/common/template-utils.mjs +29 -0
- package/lib/common/{user-utils.js → user-utils.mjs} +24 -28
- package/lib/{create-app.js → create-app.mjs} +372 -361
- package/lib/{create-server.js → create-server.mjs} +32 -11
- package/lib/debug.mjs +37 -0
- package/lib/handlers/{allow.js → allow.mjs} +79 -83
- package/lib/handlers/{auth-proxy.js → auth-proxy.mjs} +4 -5
- package/lib/handlers/{copy.js → copy.mjs} +37 -39
- package/lib/handlers/{cors-proxy.js → cors-proxy.mjs} +9 -11
- package/lib/handlers/{delete.js → delete.mjs} +20 -22
- package/lib/handlers/{error-pages.js → error-pages.mjs} +144 -212
- package/lib/handlers/{get.js → get.mjs} +254 -252
- package/lib/handlers/{index.js → index.mjs} +7 -8
- package/lib/handlers/{notify.js → notify.mjs} +8 -10
- package/lib/handlers/{options.js → options.mjs} +3 -5
- package/lib/handlers/patch/{n3-patch-parser.js → n3-patch-parser.mjs} +57 -59
- package/lib/handlers/patch/{sparql-update-parser.js → sparql-update-parser.mjs} +14 -16
- package/lib/handlers/{patch.js → patch.mjs} +241 -235
- package/lib/handlers/{post.js → post.mjs} +101 -99
- package/lib/handlers/{put.js → put.mjs} +101 -105
- package/lib/handlers/{restrict-to-top-domain.js → restrict-to-top-domain.mjs} +2 -2
- package/lib/{header.js → header.mjs} +138 -143
- package/lib/{http-error.js → http-error.mjs} +35 -34
- package/lib/{ldp-container.js → ldp-container.mjs} +10 -12
- package/lib/ldp-copy.mjs +82 -0
- package/lib/ldp-middleware.mjs +38 -0
- package/lib/{ldp.js → ldp.mjs} +286 -75
- package/lib/{lock.js → lock.mjs} +10 -10
- package/lib/{metadata.js → metadata.mjs} +11 -11
- package/lib/models/account-manager.mjs +297 -0
- package/lib/models/account-template.mjs +70 -0
- package/lib/models/authenticator.mjs +161 -0
- package/lib/models/oidc-manager.mjs +23 -0
- package/lib/models/solid-host.mjs +63 -0
- package/lib/models/user-account.mjs +50 -0
- package/lib/models/webid-tls-certificate.mjs +97 -0
- package/lib/{payment-pointer-discovery.js → payment-pointer-discovery.mjs} +5 -8
- package/lib/{rdf-notification-template.js → rdf-notification-template.mjs} +3 -5
- package/lib/requests/add-cert-request.mjs +70 -0
- package/lib/requests/auth-request.mjs +151 -0
- package/lib/requests/{create-account-request.js → create-account-request.mjs} +249 -452
- package/lib/requests/delete-account-confirm-request.mjs +85 -0
- package/lib/requests/{delete-account-request.js → delete-account-request.mjs} +73 -134
- package/lib/requests/login-request.mjs +89 -0
- package/lib/requests/{password-change-request.js → password-change-request.mjs} +132 -201
- package/lib/requests/{password-reset-email-request.js → password-reset-email-request.mjs} +123 -202
- package/lib/requests/password-reset-request.mjs +47 -0
- package/lib/requests/register-request.mjs +48 -0
- package/lib/requests/{sharing-request.js → sharing-request.mjs} +174 -261
- package/lib/{resource-mapper.js → resource-mapper.mjs} +7 -6
- package/lib/{server-config.js → server-config.mjs} +15 -20
- package/lib/services/{blacklist-service.js → blacklist-service.mjs} +36 -33
- package/lib/services/email-service.mjs +76 -0
- package/lib/services/{token-service.js → token-service.mjs} +36 -44
- package/lib/{utils.js → utils.mjs} +309 -254
- package/lib/webid/{index.js → index.mjs} +9 -13
- package/lib/webid/lib/get.mjs +31 -0
- package/lib/webid/lib/{parse.js → parse.mjs} +10 -12
- package/lib/webid/lib/verify.mjs +77 -0
- package/lib/webid/tls/generate.mjs +53 -0
- package/lib/webid/tls/index.mjs +7 -0
- package/package.json +61 -41
- package/renovate.json +0 -0
- package/robots.txt +0 -0
- package/robots.txt.acl +0 -0
- package/solid-server-5.8.8.tgz +0 -0
- package/static/account-recovery.html +0 -0
- package/static/popup-redirect.html +0 -0
- package/static/signup.html +0 -0
- package/static/signup.html.acl +0 -0
- package/test/index.mjs +168 -0
- package/test/integration/account-creation-tls-test.mjs +127 -0
- package/test/integration/account-manager-test.mjs +151 -0
- package/test/integration/account-template-test.mjs +136 -0
- package/test/integration/acl-oidc-test.mjs +1048 -0
- package/test/integration/acl-tls-test.mjs +964 -0
- package/test/integration/auth-proxy-test.mjs +144 -0
- package/test/integration/authentication-oidc-test.mjs +812 -0
- package/test/integration/authentication-oidc-with-strict-origins-turned-off-test.mjs +638 -0
- package/test/integration/capability-discovery-test.mjs +116 -0
- package/test/integration/cors-proxy-test.mjs +145 -0
- package/test/integration/errors-oidc-test.mjs +109 -0
- package/test/integration/errors-test.mjs +49 -0
- package/test/integration/formats-test.mjs +136 -0
- package/test/integration/header-test.mjs +101 -0
- package/test/integration/http-copy-test.mjs +109 -0
- package/test/integration/http-test.mjs +1197 -0
- package/test/integration/ldp-test.mjs +528 -0
- package/test/integration/oidc-manager-test.mjs +42 -0
- package/test/integration/params-test.mjs +192 -0
- package/test/integration/patch-sparql-update-test.mjs +195 -0
- package/test/integration/patch-test.mjs +590 -0
- package/test/integration/payment-pointer-test.mjs +155 -0
- package/test/integration/prep-test.mjs +314 -0
- package/test/integration/quota-test.mjs +51 -0
- package/test/integration/special-root-acl-handling-test.mjs +68 -0
- package/test/integration/validate-tts-test.mjs +57 -0
- package/test/integration/www-account-creation-oidc-test.mjs +311 -0
- package/test/keys/cert.pem +21 -0
- package/test/keys/client-cert.pem +19 -0
- package/test/keys/client-key.pem +27 -0
- package/test/keys/key.pem +27 -0
- package/test/keys/user1-cert.pem +23 -0
- package/test/keys/user1-key.pem +28 -0
- package/test/keys/user2-cert.pem +23 -0
- package/test/keys/user2-key.pem +27 -0
- package/test/mocha.opts +2 -0
- package/test/resources/Makefile +146 -0
- package/test/resources/accounts/alice.localhost/profile/card +0 -0
- package/test/resources/accounts/db/oidc/op/clients/_key_5319f8e8e4ea3214c2e92b252520d355.json +1 -0
- package/test/resources/accounts/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A3457.json +1 -0
- package/test/resources/accounts/localhost/samplePublicContainer/nicola.jpg +0 -0
- package/test/resources/accounts/tim.localhost/hello.html +9 -0
- package/test/resources/accounts/tim.localhost/profile/card +0 -0
- package/test/resources/accounts-acl/config/templates/emails/welcome-test.js +39 -0
- package/test/resources/accounts-acl/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/accounts-acl/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/accounts-acl/config/templates/new-account/index.html +28 -0
- package/test/resources/accounts-acl/config/templates/new-account/index.html.acl +22 -0
- package/test/resources/accounts-acl/config/templates/new-account/profile/card +27 -0
- package/{default-templates/new-account/inbox/.acl → test/resources/accounts-acl/config/templates/new-account/profile/card.acl} +5 -6
- package/test/resources/accounts-acl/config/templates/new-account/settings/prefs.ttl +9 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/accounts-acl/config/templates/new-account/settings/serverSide.ttl +14 -0
- package/test/resources/accounts-acl/config/templates/server/index.html +35 -0
- package/{.acl → test/resources/accounts-acl/config/templates/server/index.html.acl} +4 -3
- package/test/resources/accounts-acl/config/views/account/register.hbs +58 -0
- package/test/resources/accounts-acl/config/views/auth/consent.hbs +49 -0
- package/test/resources/accounts-acl/config/views/auth/goodbye.hbs +20 -0
- package/test/resources/accounts-acl/config/views/auth/login-required.hbs +0 -0
- package/test/resources/accounts-acl/config/views/auth/login.hbs +51 -0
- package/test/resources/accounts-acl/config/views/auth/no-permission.hbs +0 -0
- package/test/resources/accounts-acl/db/oidc/op/clients/_key_77bb3b35edb1f3f7b887c25d1211a491.json +1 -0
- package/test/resources/accounts-acl/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-acl/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7777.json +1 -0
- package/test/resources/accounts-acl/localhost/favicon.ico +0 -0
- package/test/resources/accounts-acl/localhost/index.html +35 -0
- package/{default-templates/server/.acl → test/resources/accounts-acl/localhost/index.html.acl} +4 -3
- package/test/resources/accounts-acl/nicola.localhost/index.html +1 -0
- package/test/resources/accounts-acl/nicola.localhost/index.html.acl +10 -0
- package/test/resources/accounts-acl/quota/settings/serverSide.ttl +11 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc.ttl.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc2.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/append-acl/abc2.ttl.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/fake-account/hello.html +9 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/group-listing-error.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/group-listing.ttl +14 -0
- package/test/resources/accounts-acl/tim.localhost/group/test-folder/some-other-file.txt +1 -0
- package/test/resources/accounts-acl/tim.localhost/multi-server/protected.txt +1 -0
- package/test/resources/accounts-acl/tim.localhost/multi-server/protected.txt.acl +8 -0
- package/test/resources/accounts-acl/tim.localhost/no-acl/test-file.html +1 -0
- package/test/resources/accounts-acl/tim.localhost/read-acl/deeper-tree/acls-only-on-top/example.ttl +1 -0
- package/test/resources/accounts-acl/tim.localhost/write-acl/test-file$.txt +1 -0
- package/test/resources/accounts-scenario/alice/db/oidc/op/clients/_key_9c0fd8442675a1afbe5115b9ae300c65.json +1 -0
- package/test/resources/accounts-scenario/alice/db/oidc/op/provider.json +761 -0
- package/test/resources/accounts-scenario/alice/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7000.json +1 -0
- package/test/resources/accounts-scenario/alice/private-for-alice.txt +1 -0
- package/test/resources/accounts-scenario/alice/private-for-alice.txt.acl +12 -0
- package/test/resources/accounts-scenario/alice/profile/card$.ttl +10 -0
- package/test/resources/accounts-scenario/bob/db/oidc/op/clients/_key_f15f340b6dc71b68d20eca0d7e87a972.json +1 -0
- package/test/resources/accounts-scenario/bob/db/oidc/op/provider.json +761 -0
- package/test/resources/accounts-scenario/bob/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7001.json +1 -0
- package/test/resources/accounts-scenario/bob/profile/card$.ttl +5 -0
- package/test/resources/accounts-scenario/bob/shared-with-alice.txt +1 -0
- package/test/resources/accounts-scenario/bob/shared-with-alice.txt.acl +15 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/op/clients/_key_7c634dfe325475cc8750e19c72acf6d9.json +1 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/op/provider.json +759 -0
- package/test/resources/accounts-scenario/charlie/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A5002.json +1 -0
- package/test/resources/accounts-scenario/charlie/profile/card$.ttl +5 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/op/clients/_key_3f1cecaefd21253767f6e047bd9b572f.json +1 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-strict-origin-off/alice/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7010.json +1 -0
- package/test/resources/accounts-strict-origin-off/alice/private-for-alice.txt +1 -0
- package/test/resources/accounts-strict-origin-off/alice/private-for-alice.txt.acl +12 -0
- package/test/resources/accounts-strict-origin-off/alice/profile/card$.ttl +10 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/op/clients/_key_a17f603b5907c97a5fac61a2eea7ecb2.json +1 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/op/provider.json +763 -0
- package/test/resources/accounts-strict-origin-off/bob/db/oidc/rp/clients/_key_https%3A%2F%2Flocalhost%3A7011.json +1 -0
- package/test/resources/accounts-strict-origin-off/bob/shared-with-alice.txt +1 -0
- package/test/resources/accounts-strict-origin-off/bob/shared-with-alice.txt.acl +15 -0
- package/test/resources/acl-tls/config/templates/emails/delete-account.js +49 -0
- package/test/resources/acl-tls/config/templates/emails/invalid-username.js +30 -0
- package/test/resources/acl-tls/config/templates/emails/reset-password.js +49 -0
- package/test/resources/acl-tls/config/templates/emails/welcome.js +39 -0
- package/test/resources/acl-tls/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/acl-tls/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/robots.txt +3 -0
- package/test/resources/acl-tls/config/templates/new-account/robots.txt.acl +26 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/resources/acl-tls/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/resources/acl-tls/config/templates/server/favicon.ico +0 -0
- package/test/resources/acl-tls/config/templates/server/favicon.ico.acl +15 -0
- package/test/resources/acl-tls/config/templates/server/index.html +55 -0
- package/test/resources/acl-tls/config/templates/server/robots.txt +3 -0
- package/test/resources/acl-tls/config/templates/server/robots.txt.acl +15 -0
- package/test/resources/acl-tls/config/views/account/account-deleted.hbs +17 -0
- package/test/resources/acl-tls/config/views/account/delete-confirm.hbs +51 -0
- package/test/resources/acl-tls/config/views/account/delete-link-sent.hbs +17 -0
- package/test/resources/acl-tls/config/views/account/delete.hbs +51 -0
- package/test/resources/acl-tls/config/views/account/invalid-username.hbs +22 -0
- package/test/resources/acl-tls/config/views/account/register-disabled.hbs +6 -0
- package/test/resources/acl-tls/config/views/account/register-form.hbs +147 -0
- package/test/resources/acl-tls/config/views/account/register.hbs +24 -0
- package/test/resources/acl-tls/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/resources/acl-tls/config/views/auth/change-password.hbs +58 -0
- package/test/resources/acl-tls/config/views/auth/goodbye.hbs +23 -0
- package/test/resources/acl-tls/config/views/auth/login-required.hbs +34 -0
- package/test/resources/acl-tls/config/views/auth/login-tls.hbs +11 -0
- package/test/resources/acl-tls/config/views/auth/login-username-password.hbs +28 -0
- package/test/resources/acl-tls/config/views/auth/login.hbs +55 -0
- package/test/resources/acl-tls/config/views/auth/no-permission.hbs +29 -0
- package/test/resources/acl-tls/config/views/auth/password-changed.hbs +27 -0
- package/test/resources/acl-tls/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/resources/acl-tls/config/views/auth/reset-password.hbs +52 -0
- package/test/resources/acl-tls/config/views/auth/sharing.hbs +49 -0
- package/test/resources/acl-tls/config/views/shared/create-account.hbs +8 -0
- package/test/resources/acl-tls/config/views/shared/error.hbs +5 -0
- package/test/resources/acl-tls/localhost/favicon.ico +0 -0
- package/test/resources/acl-tls/localhost/favicon.ico.acl +15 -0
- package/test/resources/acl-tls/localhost/index.html +48 -0
- package/test/resources/acl-tls/localhost/robots.txt +3 -0
- package/test/resources/acl-tls/localhost/robots.txt.acl +15 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc.ttl +1 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc.ttl.acl +8 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc2.ttl +1 -0
- package/test/resources/acl-tls/tim.localhost/append-acl/abc2.ttl.acl +8 -0
- package/test/resources/acl-tls/tim.localhost/fake-account/hello.html +9 -0
- package/test/resources/acl-tls/tim.localhost/no-acl/test-file.html +1 -0
- package/test/resources/acl-tls/tim.localhost/profile/card$.ttl +17 -0
- package/test/resources/acl-tls/write-acl/test-file$.ttl +1 -0
- package/test/resources/auth-proxy/index.html +0 -0
- package/test/resources/auth-proxy/index.html.acl +0 -0
- package/test/resources/config/templates/emails/delete-account.js +49 -0
- package/test/resources/config/templates/emails/delete-account.mjs +31 -0
- package/test/resources/config/templates/emails/invalid-username.js +30 -0
- package/test/resources/config/templates/emails/invalid-username.mjs +27 -0
- package/test/resources/config/templates/emails/reset-password.js +49 -0
- package/test/resources/config/templates/emails/reset-password.mjs +31 -0
- package/test/resources/config/templates/emails/welcome.js +39 -0
- package/test/resources/config/templates/emails/welcome.mjs +23 -0
- package/test/resources/config/templates/new-account/favicon.ico +0 -0
- package/test/resources/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/resources/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/resources/config/templates/new-account/robots.txt +3 -0
- package/test/resources/config/templates/new-account/robots.txt.acl +26 -0
- package/test/resources/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/resources/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/resources/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/resources/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/resources/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/resources/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/resources/config/templates/server/favicon.ico +0 -0
- package/test/resources/config/templates/server/favicon.ico.acl +15 -0
- package/test/resources/config/templates/server/index.html +54 -0
- package/test/resources/config/templates/server/robots.txt +3 -0
- package/test/resources/config/templates/server/robots.txt.acl +15 -0
- package/test/resources/config/views/account/account-deleted.hbs +17 -0
- package/test/resources/config/views/account/delete-confirm.hbs +51 -0
- package/test/resources/config/views/account/delete-link-sent.hbs +17 -0
- package/test/resources/config/views/account/delete.hbs +51 -0
- package/test/resources/config/views/account/invalid-username.hbs +22 -0
- package/test/resources/config/views/account/register-disabled.hbs +6 -0
- package/test/resources/config/views/account/register-form.hbs +133 -0
- package/test/resources/config/views/account/register.hbs +24 -0
- package/test/resources/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/resources/config/views/auth/change-password.hbs +58 -0
- package/test/resources/config/views/auth/goodbye.hbs +23 -0
- package/test/resources/config/views/auth/login-required.hbs +34 -0
- package/test/resources/config/views/auth/login-tls.hbs +11 -0
- package/test/resources/config/views/auth/login-username-password.hbs +28 -0
- package/test/resources/config/views/auth/login.hbs +55 -0
- package/test/resources/config/views/auth/no-permission.hbs +29 -0
- package/test/resources/config/views/auth/password-changed.hbs +27 -0
- package/test/resources/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/resources/config/views/auth/reset-password.hbs +52 -0
- package/test/resources/config/views/auth/sharing.hbs +49 -0
- package/test/resources/config/views/shared/create-account.hbs +8 -0
- package/test/resources/config/views/shared/error.hbs +5 -0
- package/test/resources/empty.spatch +0 -0
- package/test/resources/errorPages/401.html +5 -0
- package/test/resources/errorPages/403.html +5 -0
- package/test/resources/errorPages/404.html +5 -0
- package/test/resources/errorPages/405.html +5 -0
- package/test/resources/errorPages/415.html +5 -0
- package/test/resources/errorPages/500.html +5 -0
- package/test/resources/example_spkac.cnf +1 -0
- package/test/resources/external-servers/example.com/jwks.json +81 -0
- package/test/resources/external-servers/example.com/openid-configuration.json +53 -0
- package/test/resources/favicon.ico +0 -0
- package/test/resources/favicon.ico.acl +15 -0
- package/test/resources/headers/index.html +0 -0
- package/test/resources/headers/public-ra +0 -0
- package/test/resources/headers/public-ra.acl +7 -0
- package/test/resources/headers/user-rw-public-r +0 -0
- package/test/resources/headers/user-rw-public-r.acl +12 -0
- package/test/resources/headers/user-rwac-public-0 +0 -0
- package/test/resources/headers/user-rwac-public-0.acl +7 -0
- package/test/resources/hello.html +3 -0
- package/test/resources/invalid1.ttl +13 -0
- package/test/resources/invalid2.ttl +9 -0
- package/test/resources/ldpatch-example-final.ttl +23 -0
- package/test/resources/ldpatch-example-initial.ttl +22 -0
- package/test/resources/ldpatch-example-patch-1.spatch +8 -0
- package/test/resources/ldpatch-example-patch-2.spatch +12 -0
- package/test/resources/ldpatch-example-patch-3.spatch +14 -0
- package/test/resources/ldpatch-example-patch.ldpatch +25 -0
- package/test/resources/ldpatch-example-patch.spatch +24 -0
- package/test/resources/lennon.jsonld +7 -0
- package/test/resources/lfs-0.sparql +9 -0
- package/test/resources/lfs-1-final.json +10 -0
- package/test/resources/lfs-1.sparql +11 -0
- package/test/resources/messaging-scenario/user1.databox.me/profile/card +21 -0
- package/test/resources/nicola.jpg +0 -0
- package/test/resources/patch/append-only.ttl +2 -0
- package/test/resources/patch/append-only.ttl.acl +6 -0
- package/test/resources/patch/favicon.ico +0 -0
- package/test/resources/patch/favicon.ico.acl +15 -0
- package/test/resources/patch/index.html +0 -0
- package/test/resources/patch/read-append.ttl +2 -0
- package/test/resources/patch/read-append.ttl.acl +6 -0
- package/test/resources/patch/read-only.ttl +2 -0
- package/test/resources/patch/read-only.ttl.acl +6 -0
- package/test/resources/patch/read-write.ttl +2 -0
- package/test/resources/patch/read-write.ttl.acl +6 -0
- package/test/resources/patch/robots.txt +3 -0
- package/test/resources/patch/robots.txt.acl +15 -0
- package/test/resources/patch/write-only.ttl +2 -0
- package/test/resources/patch/write-only.ttl.acl +6 -0
- package/test/resources/patch-1-initial.ttl +3 -0
- package/test/resources/patch-2-final.ttl +2 -0
- package/test/resources/patch-2-initial.ttl +3 -0
- package/test/resources/patch-2.spatch +2 -0
- package/test/resources/patch-2n.spatch +2 -0
- package/test/resources/patch-3-final.ttl +28 -0
- package/test/resources/patch-4-final.ttl +29 -0
- package/test/resources/patch-5-final.ttl +1 -0
- package/test/resources/patch-5-initial.ttl +3 -0
- package/test/resources/patch-5.spatch +2 -0
- package/test/resources/put-input-2.html +13 -0
- package/test/resources/put-input.txt +6 -0
- package/test/resources/robots.txt +3 -0
- package/test/resources/robots.txt.acl +15 -0
- package/test/resources/sampleContainer/blank +0 -0
- package/test/resources/sampleContainer/cert.pkcs +0 -0
- package/test/resources/sampleContainer/example.ttl.old +1 -0
- package/test/resources/sampleContainer/example1.ttl +12 -0
- package/test/resources/sampleContainer/example2.ttl +3 -0
- package/test/resources/sampleContainer/example3.ttl +7 -0
- package/test/resources/sampleContainer/example4$.ttl +7 -0
- package/test/resources/sampleContainer/filename with spaces.txt +0 -0
- package/test/resources/sampleContainer/index.html +9 -0
- package/test/resources/sampleContainer/post2.ttl +6 -0
- package/test/resources/sampleContainer/put1.ttl +13 -0
- package/test/resources/sampleContainer/solid.png +0 -0
- package/test/resources/sampleContainer/user1.pfx +0 -0
- package/test/resources/sampleContainer/user2.pfx +0 -0
- package/test/resources/sampleContainer2/example1.ttl +10 -0
- package/test/resources/sampleContainer2/example2.ttl +7 -0
- package/test/resources/timbl.jpg +0 -0
- package/test/scenarios.md +23 -0
- package/test/surface/docker/cookie/Dockerfile +6 -0
- package/test/surface/docker/cookie/app/index.js +29 -0
- package/test/surface/docker/cookie/app/package-lock.json +13 -0
- package/test/surface/docker/cookie/app/package.json +14 -0
- package/test/surface/docker/server/Dockerfile +19 -0
- package/test/surface/docker/server/config/defaults.js +10 -0
- package/test/surface/docker/server/config/templates/emails/delete-account.js +49 -0
- package/test/surface/docker/server/config/templates/emails/invalid-username.js +30 -0
- package/test/surface/docker/server/config/templates/emails/reset-password.js +49 -0
- package/test/surface/docker/server/config/templates/emails/welcome.js +39 -0
- package/test/surface/docker/server/config/templates/new-account/favicon.ico +0 -0
- package/test/surface/docker/server/config/templates/new-account/favicon.ico.acl +26 -0
- package/test/surface/docker/server/config/templates/new-account/profile/card$.ttl +26 -0
- package/test/surface/docker/server/config/templates/new-account/robots.txt +3 -0
- package/test/surface/docker/server/config/templates/new-account/robots.txt.acl +26 -0
- package/test/surface/docker/server/config/templates/new-account/settings/prefs.ttl +15 -0
- package/test/surface/docker/server/config/templates/new-account/settings/privateTypeIndex.ttl +4 -0
- package/test/surface/docker/server/config/templates/new-account/settings/publicTypeIndex.ttl +4 -0
- package/test/surface/docker/server/config/templates/new-account/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/surface/docker/server/config/templates/new-account/settings/serverSide.ttl.acl +13 -0
- package/test/surface/docker/server/config/templates/new-account/settings/serverSide.ttl.inactive +12 -0
- package/test/surface/docker/server/config/templates/server/favicon.ico +0 -0
- package/test/surface/docker/server/config/templates/server/favicon.ico.acl +15 -0
- package/test/surface/docker/server/config/templates/server/index.html +55 -0
- package/test/surface/docker/server/config/templates/server/robots.txt +3 -0
- package/test/surface/docker/server/config/templates/server/robots.txt.acl +15 -0
- package/test/surface/docker/server/config/usernames-blacklist.json +4 -0
- package/test/surface/docker/server/config/views/account/account-deleted.hbs +17 -0
- package/test/surface/docker/server/config/views/account/delete-confirm.hbs +51 -0
- package/test/surface/docker/server/config/views/account/delete-link-sent.hbs +17 -0
- package/test/surface/docker/server/config/views/account/delete.hbs +51 -0
- package/test/surface/docker/server/config/views/account/invalid-username.hbs +22 -0
- package/test/surface/docker/server/config/views/account/register-disabled.hbs +6 -0
- package/test/surface/docker/server/config/views/account/register-form.hbs +147 -0
- package/test/surface/docker/server/config/views/account/register.hbs +24 -0
- package/test/surface/docker/server/config/views/auth/auth-hidden-fields.hbs +8 -0
- package/test/surface/docker/server/config/views/auth/change-password.hbs +58 -0
- package/test/surface/docker/server/config/views/auth/goodbye.hbs +23 -0
- package/test/surface/docker/server/config/views/auth/login-required.hbs +34 -0
- package/test/surface/docker/server/config/views/auth/login-tls.hbs +11 -0
- package/test/surface/docker/server/config/views/auth/login-username-password.hbs +28 -0
- package/test/surface/docker/server/config/views/auth/login.hbs +55 -0
- package/test/surface/docker/server/config/views/auth/no-permission.hbs +29 -0
- package/test/surface/docker/server/config/views/auth/password-changed.hbs +27 -0
- package/test/surface/docker/server/config/views/auth/reset-link-sent.hbs +21 -0
- package/test/surface/docker/server/config/views/auth/reset-password.hbs +52 -0
- package/test/surface/docker/server/config/views/auth/sharing.hbs +49 -0
- package/test/surface/docker/server/config/views/shared/create-account.hbs +8 -0
- package/test/surface/docker/server/config/views/shared/error.hbs +5 -0
- package/test/surface/docker/server/config.json +22 -0
- package/test/surface/docker/server/data/favicon.ico +0 -0
- package/test/surface/docker/server/data/favicon.ico.acl +26 -0
- package/test/surface/docker/server/data/index.html +48 -0
- package/test/surface/docker/server/data/profile/card$.ttl +31 -0
- package/test/surface/docker/server/data/robots.txt +3 -0
- package/test/surface/docker/server/data/robots.txt.acl +26 -0
- package/test/surface/docker/server/data/settings/prefs.ttl +15 -0
- package/test/surface/docker/server/data/settings/privateTypeIndex.ttl +4 -0
- package/test/surface/docker/server/data/settings/publicTypeIndex.ttl +4 -0
- package/test/surface/docker/server/data/settings/publicTypeIndex.ttl.acl +25 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl +0 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl.acl +13 -0
- package/test/surface/docker/server/data/settings/serverSide.ttl.inactive +12 -0
- package/test/surface/docker/server/env.list +4 -0
- package/test/surface/docker/solid-crud/Dockerfile +4 -0
- package/test/surface/docker/web-access-control/Dockerfile +1 -0
- package/test/surface/docker/webid-provider/Dockerfile +1 -0
- package/test/surface/run-solid-test-suite.sh +75 -0
- package/test/surface/server-env.list +5 -0
- package/test/surface/solid-crud-tests-env.list +5 -0
- package/test/surface/thirdparty-config.json +23 -0
- package/test/surface/thirdparty-env.list +6 -0
- package/test/surface/web-access-control-tests-env.list +6 -0
- package/test/surface/webid-provider-tests-env.list +4 -0
- package/test/test-helpers.mjs +63 -0
- package/test/unit/account-manager-test.mjs +610 -0
- package/test/unit/account-template-test.mjs +59 -0
- package/test/unit/acl-checker-test.mjs +51 -0
- package/test/unit/add-cert-request-test.mjs +120 -0
- package/test/unit/auth-handlers-test.mjs +108 -0
- package/test/unit/auth-proxy-test.mjs +224 -0
- package/test/unit/auth-request-test.mjs +96 -0
- package/test/unit/authenticator-test.mjs +34 -0
- package/test/unit/blacklist-service-test.mjs +49 -0
- package/test/unit/create-account-request-test.mjs +306 -0
- package/test/unit/delete-account-confirm-request-test.mjs +234 -0
- package/test/unit/delete-account-request-test.mjs +180 -0
- package/test/unit/email-service-test.mjs +166 -0
- package/test/unit/email-welcome-test.mjs +81 -0
- package/test/unit/error-pages-test.mjs +100 -0
- package/test/unit/esm-imports.test.mjs +149 -0
- package/test/unit/force-user-test.mjs +73 -0
- package/test/unit/getAvailableUrl-test.mjs +30 -0
- package/test/unit/getTrustedOrigins-test.mjs +20 -0
- package/test/unit/login-request-test.mjs +246 -0
- package/test/unit/oidc-manager-test.mjs +50 -0
- package/test/unit/password-authenticator-test.mjs +125 -0
- package/test/unit/password-change-request-test.mjs +259 -0
- package/test/unit/password-reset-email-request-test.mjs +234 -0
- package/test/unit/resource-mapper-test.mjs +673 -0
- package/test/unit/solid-host-test.mjs +119 -0
- package/test/unit/tls-authenticator-test.mjs +174 -0
- package/test/unit/token-service-test.mjs +82 -0
- package/test/unit/user-account-test.mjs +38 -0
- package/test/unit/user-accounts-api-test.mjs +59 -0
- package/test/unit/user-utils-test.mjs +64 -0
- package/test/unit/utils-test.mjs +114 -0
- package/test/utils/index.mjs +167 -0
- package/test/utils.mjs +205 -0
- package/test/validate-turtle.mjs +43 -0
- package/.github/workflows/ci.yml +0 -113
- package/.nvmrc +0 -1
- package/.snyk +0 -35
- package/bin/lib/cli-utils.js +0 -85
- package/bin/lib/cli.js +0 -39
- package/bin/solid.js +0 -3
- package/default-templates/new-account/.acl +0 -26
- package/default-templates/new-account/.meta +0 -5
- package/default-templates/new-account/.well-known/.acl +0 -19
- package/default-templates/new-account/private/.acl +0 -10
- package/default-templates/new-account/profile/.acl +0 -19
- package/default-templates/new-account/public/.acl +0 -19
- package/default-templates/new-account/settings/.acl +0 -20
- package/index.js +0 -3
- package/lib/api/authn/index.js +0 -5
- package/lib/api/index.js +0 -6
- package/lib/common/template-utils.js +0 -50
- package/lib/debug.js +0 -18
- package/lib/ldp-copy.js +0 -73
- package/lib/ldp-middleware.js +0 -40
- package/lib/models/account-manager.js +0 -604
- package/lib/models/account-template.js +0 -156
- package/lib/models/authenticator.js +0 -337
- package/lib/models/oidc-manager.js +0 -53
- package/lib/models/solid-host.js +0 -131
- package/lib/models/user-account.js +0 -113
- package/lib/models/webid-tls-certificate.js +0 -184
- package/lib/requests/add-cert-request.js +0 -138
- package/lib/requests/auth-request.js +0 -234
- package/lib/requests/delete-account-confirm-request.js +0 -170
- package/lib/requests/login-request.js +0 -205
- package/lib/services/email-service.js +0 -162
- package/lib/webid/lib/get.js +0 -27
- package/lib/webid/tls/index.js +0 -185
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { URL } from 'url'
|
|
2
|
+
import rdf from 'rdflib'
|
|
3
|
+
import vocab from 'solid-namespace'
|
|
4
|
+
import defaults from '../../config/defaults.mjs'
|
|
5
|
+
import UserAccount from './user-account.mjs'
|
|
6
|
+
import AccountTemplate, { TEMPLATE_EXTENSIONS, TEMPLATE_FILES } from './account-template.mjs'
|
|
7
|
+
import debugModule from './../debug.mjs'
|
|
8
|
+
const ns = vocab(rdf)
|
|
9
|
+
|
|
10
|
+
const debug = debugModule.accounts
|
|
11
|
+
const DEFAULT_PROFILE_CONTENT_TYPE = 'text/turtle'
|
|
12
|
+
const DEFAULT_ADMIN_USERNAME = 'admin'
|
|
13
|
+
|
|
14
|
+
class AccountManager {
|
|
15
|
+
constructor (options = {}) {
|
|
16
|
+
if (!options.host) {
|
|
17
|
+
throw Error('AccountManager requires a host instance')
|
|
18
|
+
}
|
|
19
|
+
this.host = options.host
|
|
20
|
+
this.emailService = options.emailService
|
|
21
|
+
this.tokenService = options.tokenService
|
|
22
|
+
this.authMethod = options.authMethod || defaults.auth
|
|
23
|
+
this.multiuser = options.multiuser || false
|
|
24
|
+
this.store = options.store
|
|
25
|
+
this.pathCard = options.pathCard || 'profile/card'
|
|
26
|
+
this.suffixURI = options.suffixURI || '#me'
|
|
27
|
+
this.accountTemplatePath = options.accountTemplatePath || './default-templates/new-account/'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static from (options) {
|
|
31
|
+
return new AccountManager(options)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
accountExists (accountName) {
|
|
35
|
+
let accountUri
|
|
36
|
+
let cardPath
|
|
37
|
+
try {
|
|
38
|
+
accountUri = this.accountUriFor(accountName)
|
|
39
|
+
accountUri = new URL(accountUri).hostname
|
|
40
|
+
// `pathCard` is a path fragment like 'profile/card' -> ensure it starts with '/'
|
|
41
|
+
cardPath = this.pathCard && this.pathCard.startsWith('/') ? this.pathCard : '/' + this.pathCard
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return Promise.reject(err)
|
|
44
|
+
}
|
|
45
|
+
return this.accountUriExists(accountUri, cardPath)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async accountUriExists (accountUri, accountResource = '/') {
|
|
49
|
+
try {
|
|
50
|
+
return await this.store.exists(accountUri, accountResource)
|
|
51
|
+
} catch (err) {
|
|
52
|
+
return false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
accountDirFor (accountName) {
|
|
57
|
+
const { hostname } = new URL(this.accountUriFor(accountName))
|
|
58
|
+
return this.store.resourceMapper.resolveFilePath(hostname)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
accountUriFor (accountName) {
|
|
62
|
+
const accountUri = this.multiuser
|
|
63
|
+
? this.host.accountUriFor(accountName)
|
|
64
|
+
: this.host.serverUri
|
|
65
|
+
return accountUri
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
accountWebIdFor (accountName) {
|
|
69
|
+
const accountUri = this.accountUriFor(accountName)
|
|
70
|
+
const webIdUri = new URL(this.pathCard, accountUri)
|
|
71
|
+
webIdUri.hash = this.suffixURI
|
|
72
|
+
return webIdUri.toString()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
rootAclFor (userAccount) {
|
|
76
|
+
const accountUri = this.accountUriFor(userAccount.username)
|
|
77
|
+
return new URL(this.store.suffixAcl, accountUri).toString()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
addCertKeyToProfile (certificate, userAccount) {
|
|
81
|
+
if (!certificate) {
|
|
82
|
+
throw new TypeError('Cannot add empty certificate to user profile')
|
|
83
|
+
}
|
|
84
|
+
return this.getProfileGraphFor(userAccount)
|
|
85
|
+
.then(profileGraph => this.addCertKeyToGraph(certificate, profileGraph))
|
|
86
|
+
.then(profileGraph => this.saveProfileGraph(profileGraph, userAccount))
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
getProfileGraphFor (userAccount, contentType = DEFAULT_PROFILE_CONTENT_TYPE) {
|
|
90
|
+
const webId = userAccount.webId
|
|
91
|
+
if (!webId) {
|
|
92
|
+
const error = new Error('Cannot fetch profile graph, missing WebId URI')
|
|
93
|
+
error.status = 400
|
|
94
|
+
return Promise.reject(error)
|
|
95
|
+
}
|
|
96
|
+
const uri = userAccount.profileUri
|
|
97
|
+
return this.store.getGraph(uri, contentType)
|
|
98
|
+
.catch(error => {
|
|
99
|
+
error.message = `Error retrieving profile graph ${uri}: ` + error.message
|
|
100
|
+
throw error
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
saveProfileGraph (profileGraph, userAccount, contentType = DEFAULT_PROFILE_CONTENT_TYPE) {
|
|
105
|
+
const webId = userAccount.webId
|
|
106
|
+
if (!webId) {
|
|
107
|
+
const error = new Error('Cannot save profile graph, missing WebId URI')
|
|
108
|
+
error.status = 400
|
|
109
|
+
return Promise.reject(error)
|
|
110
|
+
}
|
|
111
|
+
const uri = userAccount.profileUri
|
|
112
|
+
return this.store.putGraph(profileGraph, uri, contentType)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
addCertKeyToGraph (certificate, graph) {
|
|
116
|
+
const webId = rdf.namedNode(certificate.webId)
|
|
117
|
+
const key = rdf.namedNode(certificate.keyUri)
|
|
118
|
+
const timeCreated = rdf.literal(certificate.date.toISOString(), ns.xsd('dateTime'))
|
|
119
|
+
const modulus = rdf.literal(certificate.modulus, ns.xsd('hexBinary'))
|
|
120
|
+
const exponent = rdf.literal(certificate.exponent, ns.xsd('int'))
|
|
121
|
+
const title = rdf.literal('Created by solid-server')
|
|
122
|
+
const label = rdf.literal(certificate.commonName)
|
|
123
|
+
graph.add(webId, ns.cert('key'), key)
|
|
124
|
+
graph.add(key, ns.rdf('type'), ns.cert('RSAPublicKey'))
|
|
125
|
+
graph.add(key, ns.dct('title'), title)
|
|
126
|
+
graph.add(key, ns.rdfs('label'), label)
|
|
127
|
+
graph.add(key, ns.dct('created'), timeCreated)
|
|
128
|
+
graph.add(key, ns.cert('modulus'), modulus)
|
|
129
|
+
graph.add(key, ns.cert('exponent'), exponent)
|
|
130
|
+
return graph
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
userAccountFrom (userData) {
|
|
134
|
+
const userConfig = {
|
|
135
|
+
username: userData.username,
|
|
136
|
+
email: userData.email,
|
|
137
|
+
name: userData.name,
|
|
138
|
+
externalWebId: userData.externalWebId,
|
|
139
|
+
localAccountId: userData.localAccountId,
|
|
140
|
+
webId: userData.webid || userData.webId || userData.externalWebId,
|
|
141
|
+
idp: this.host.serverUri
|
|
142
|
+
}
|
|
143
|
+
if (userConfig.username) {
|
|
144
|
+
userConfig.username = userConfig.username.toLowerCase()
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
userConfig.webId = userConfig.webId || this.accountWebIdFor(userConfig.username)
|
|
148
|
+
} catch (err) {
|
|
149
|
+
if (err.message === 'Cannot construct uri for blank account name') {
|
|
150
|
+
throw new Error('Username or web id is required')
|
|
151
|
+
} else {
|
|
152
|
+
throw err
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (userConfig.username) {
|
|
156
|
+
if (userConfig.externalWebId && !userConfig.localAccountId) {
|
|
157
|
+
userConfig.localAccountId = this.accountWebIdFor(userConfig.username)
|
|
158
|
+
.split('//')[1]
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
if (userConfig.externalWebId) {
|
|
162
|
+
userConfig.username = userConfig.externalWebId
|
|
163
|
+
} else {
|
|
164
|
+
userConfig.username = this.usernameFromWebId(userConfig.webId)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return UserAccount.from(userConfig)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
usernameFromWebId (webId) {
|
|
171
|
+
if (!this.multiuser) {
|
|
172
|
+
return DEFAULT_ADMIN_USERNAME
|
|
173
|
+
}
|
|
174
|
+
const profileUrl = new URL(webId)
|
|
175
|
+
const hostname = profileUrl.hostname
|
|
176
|
+
return hostname.split('.')[0]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
createAccountFor (userAccount) {
|
|
180
|
+
const template = AccountTemplate.for(userAccount)
|
|
181
|
+
const templatePath = this.accountTemplatePath
|
|
182
|
+
const accountDir = this.accountDirFor(userAccount.username)
|
|
183
|
+
debug(`Creating account folder for ${userAccount.webId} at ${accountDir}`)
|
|
184
|
+
return AccountTemplate.copyTemplateDir(templatePath, accountDir)
|
|
185
|
+
.then(() => template.processAccount(accountDir))
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
generateResetToken (userAccount) {
|
|
189
|
+
return this.tokenService.generate('reset-password', { webId: userAccount.webId })
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
generateDeleteToken (userAccount) {
|
|
193
|
+
return this.tokenService.generate('delete-account.mjs', {
|
|
194
|
+
webId: userAccount.webId,
|
|
195
|
+
email: userAccount.email
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
validateDeleteToken (token) {
|
|
200
|
+
const tokenValue = this.tokenService.verify('delete-account.mjs', token)
|
|
201
|
+
if (!tokenValue) {
|
|
202
|
+
throw new Error('Invalid or expired delete account token')
|
|
203
|
+
}
|
|
204
|
+
return tokenValue
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
validateResetToken (token) {
|
|
208
|
+
const tokenValue = this.tokenService.verify('reset-password', token)
|
|
209
|
+
if (!tokenValue) {
|
|
210
|
+
throw new Error('Invalid or expired reset token')
|
|
211
|
+
}
|
|
212
|
+
return tokenValue
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
passwordResetUrl (token, returnToUrl) {
|
|
216
|
+
let resetUrl = new URL(`/account/password/change?token=${token}`, this.host.serverUri).toString()
|
|
217
|
+
if (returnToUrl) {
|
|
218
|
+
resetUrl += `&returnToUrl=${returnToUrl}`
|
|
219
|
+
}
|
|
220
|
+
return resetUrl
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
getAccountDeleteUrl (token) {
|
|
224
|
+
return new URL(`/account/delete/confirm?token=${token}`, this.host.serverUri).toString()
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
loadAccountRecoveryEmail (userAccount) {
|
|
228
|
+
return Promise.resolve()
|
|
229
|
+
.then(() => {
|
|
230
|
+
const rootAclUri = this.rootAclFor(userAccount)
|
|
231
|
+
return this.store.getGraph(rootAclUri)
|
|
232
|
+
})
|
|
233
|
+
.then(rootAclGraph => {
|
|
234
|
+
const matches = rootAclGraph.match(null, ns.acl('agent'))
|
|
235
|
+
let recoveryMailto = matches.find(agent => agent.object.value.startsWith('mailto:'))
|
|
236
|
+
if (recoveryMailto) {
|
|
237
|
+
recoveryMailto = recoveryMailto.object.value.replace('mailto:', '')
|
|
238
|
+
}
|
|
239
|
+
return recoveryMailto
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
verifyEmailDependencies (userAccount) {
|
|
244
|
+
if (!this.emailService) {
|
|
245
|
+
throw new Error('Email service is not set up')
|
|
246
|
+
}
|
|
247
|
+
if (userAccount && !userAccount.email) {
|
|
248
|
+
throw new Error('Account recovery email has not been provided')
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
sendDeleteAccountEmail (userAccount) {
|
|
253
|
+
return Promise.resolve()
|
|
254
|
+
.then(() => this.verifyEmailDependencies(userAccount))
|
|
255
|
+
.then(() => this.generateDeleteToken(userAccount))
|
|
256
|
+
.then(resetToken => {
|
|
257
|
+
const deleteUrl = this.getAccountDeleteUrl(resetToken)
|
|
258
|
+
const emailData = {
|
|
259
|
+
to: userAccount.email,
|
|
260
|
+
webId: userAccount.webId,
|
|
261
|
+
deleteUrl: deleteUrl
|
|
262
|
+
}
|
|
263
|
+
return this.emailService.sendWithTemplate('delete-account.mjs', emailData)
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
sendPasswordResetEmail (userAccount, returnToUrl) {
|
|
268
|
+
return Promise.resolve()
|
|
269
|
+
.then(() => this.verifyEmailDependencies(userAccount))
|
|
270
|
+
.then(() => this.generateResetToken(userAccount))
|
|
271
|
+
.then(resetToken => {
|
|
272
|
+
const resetUrl = this.passwordResetUrl(resetToken, returnToUrl)
|
|
273
|
+
const emailData = {
|
|
274
|
+
to: userAccount.email,
|
|
275
|
+
webId: userAccount.webId,
|
|
276
|
+
resetUrl
|
|
277
|
+
}
|
|
278
|
+
return this.emailService.sendWithTemplate('reset-password', emailData)
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
sendWelcomeEmail (newUser) {
|
|
283
|
+
const emailService = this.emailService
|
|
284
|
+
if (!emailService || !newUser.email) {
|
|
285
|
+
return Promise.resolve(null)
|
|
286
|
+
}
|
|
287
|
+
const emailData = {
|
|
288
|
+
to: newUser.email,
|
|
289
|
+
webid: newUser.webId,
|
|
290
|
+
name: newUser.displayName
|
|
291
|
+
}
|
|
292
|
+
return emailService.sendWithTemplate('welcome', emailData)
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export default AccountManager
|
|
297
|
+
export { TEMPLATE_EXTENSIONS, TEMPLATE_FILES }
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import mime from 'mime-types'
|
|
3
|
+
import recursiveRead from 'recursive-readdir'
|
|
4
|
+
import * as fsUtils from '../common/fs-utils.mjs'
|
|
5
|
+
import * as templateUtils from '../common/template-utils.mjs'
|
|
6
|
+
import LDP from '../ldp.mjs'
|
|
7
|
+
import { URL } from 'url'
|
|
8
|
+
|
|
9
|
+
export const TEMPLATE_EXTENSIONS = ['.acl', '.meta', '.json', '.hbs', '.handlebars']
|
|
10
|
+
export const TEMPLATE_FILES = ['card']
|
|
11
|
+
|
|
12
|
+
class AccountTemplate {
|
|
13
|
+
constructor (options = {}) {
|
|
14
|
+
this.substitutions = options.substitutions || {}
|
|
15
|
+
this.templateExtensions = options.templateExtensions || TEMPLATE_EXTENSIONS
|
|
16
|
+
this.templateFiles = options.templateFiles || TEMPLATE_FILES
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static for (userAccount, options = {}) {
|
|
20
|
+
const substitutions = AccountTemplate.templateSubstitutionsFor(userAccount)
|
|
21
|
+
options = Object.assign({ substitutions }, options)
|
|
22
|
+
return new AccountTemplate(options)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static copyTemplateDir (templatePath, accountPath) {
|
|
26
|
+
return fsUtils.copyTemplateDir(templatePath, accountPath)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static templateSubstitutionsFor (userAccount) {
|
|
30
|
+
const webUri = new URL(userAccount.webId)
|
|
31
|
+
const podRelWebId = userAccount.webId.replace(webUri.origin, '')
|
|
32
|
+
const substitutions = {
|
|
33
|
+
name: userAccount.displayName,
|
|
34
|
+
webId: userAccount.externalWebId ? userAccount.webId : podRelWebId,
|
|
35
|
+
email: userAccount.email,
|
|
36
|
+
idp: userAccount.idp
|
|
37
|
+
}
|
|
38
|
+
return substitutions
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
readAccountFiles (accountPath) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
recursiveRead(accountPath, (error, files) => {
|
|
44
|
+
if (error) { return reject(error) }
|
|
45
|
+
resolve(files)
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
readTemplateFiles (accountPath) {
|
|
51
|
+
return this.readAccountFiles(accountPath)
|
|
52
|
+
.then(files => files.filter((file) => this.isTemplate(file)))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
processAccount (accountPath) {
|
|
56
|
+
return this.readTemplateFiles(accountPath)
|
|
57
|
+
.then(files => Promise.all(files.map(path => templateUtils.processHandlebarFile(path, this.substitutions))))
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
isTemplate (filePath) {
|
|
61
|
+
const parsed = path.parse(filePath)
|
|
62
|
+
const mimeType = mime.lookup(filePath)
|
|
63
|
+
const isRdf = LDP.mimeTypeIsRdf(mimeType)
|
|
64
|
+
const isTemplateExtension = this.templateExtensions.includes(parsed.ext)
|
|
65
|
+
const isTemplateFile = this.templateFiles.includes(parsed.base) || this.templateExtensions.includes(parsed.base)
|
|
66
|
+
return isRdf || isTemplateExtension || isTemplateFile
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default AccountTemplate
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import debugModule from './../debug.mjs'
|
|
2
|
+
import validUrl from 'valid-url'
|
|
3
|
+
import * as webid from '../webid/tls/index.mjs'
|
|
4
|
+
import provider from '@solid/oidc-auth-manager/src/preferred-provider.js'
|
|
5
|
+
import oidcManager from '@solid/oidc-auth-manager/src/oidc-manager.js'
|
|
6
|
+
const { domainMatches } = oidcManager
|
|
7
|
+
|
|
8
|
+
const debug = debugModule.authentication
|
|
9
|
+
|
|
10
|
+
export class Authenticator {
|
|
11
|
+
constructor (options) {
|
|
12
|
+
this.accountManager = options.accountManager
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static fromParams (req, options) {
|
|
16
|
+
throw new Error('Must override method')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
findValidUser () {
|
|
20
|
+
throw new Error('Must override method')
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class PasswordAuthenticator extends Authenticator {
|
|
25
|
+
constructor (options) {
|
|
26
|
+
super(options)
|
|
27
|
+
this.userStore = options.userStore
|
|
28
|
+
this.username = options.username
|
|
29
|
+
this.password = options.password
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static fromParams (req, options) {
|
|
33
|
+
const body = req.body || {}
|
|
34
|
+
options.username = body.username
|
|
35
|
+
options.password = body.password
|
|
36
|
+
return new PasswordAuthenticator(options)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
validate () {
|
|
40
|
+
let error
|
|
41
|
+
if (!this.username) {
|
|
42
|
+
error = new Error('Username required')
|
|
43
|
+
error.statusCode = 400
|
|
44
|
+
throw error
|
|
45
|
+
}
|
|
46
|
+
if (!this.password) {
|
|
47
|
+
error = new Error('Password required')
|
|
48
|
+
error.statusCode = 400
|
|
49
|
+
throw error
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
findValidUser () {
|
|
54
|
+
let error
|
|
55
|
+
let userOptions
|
|
56
|
+
return Promise.resolve()
|
|
57
|
+
.then(() => this.validate())
|
|
58
|
+
.then(() => {
|
|
59
|
+
if (validUrl.isUri(this.username)) {
|
|
60
|
+
userOptions = { webId: this.username }
|
|
61
|
+
} else {
|
|
62
|
+
userOptions = { username: this.username }
|
|
63
|
+
}
|
|
64
|
+
const user = this.accountManager.userAccountFrom(userOptions)
|
|
65
|
+
debug(`Attempting to login user: ${user.id}`)
|
|
66
|
+
return this.userStore.findUser(user.id)
|
|
67
|
+
})
|
|
68
|
+
.then(foundUser => {
|
|
69
|
+
if (!foundUser) {
|
|
70
|
+
error = new Error('Invalid username/password combination.')
|
|
71
|
+
error.statusCode = 400
|
|
72
|
+
throw error
|
|
73
|
+
}
|
|
74
|
+
if (foundUser.link) {
|
|
75
|
+
throw new Error('Linked users not currently supported, sorry (external WebID without TLS?)')
|
|
76
|
+
}
|
|
77
|
+
return this.userStore.matchPassword(foundUser, this.password)
|
|
78
|
+
})
|
|
79
|
+
.then(validUser => {
|
|
80
|
+
if (!validUser) {
|
|
81
|
+
error = new Error('Invalid username/password combination.')
|
|
82
|
+
error.statusCode = 400
|
|
83
|
+
throw error
|
|
84
|
+
}
|
|
85
|
+
debug('User found, password matches')
|
|
86
|
+
return this.accountManager.userAccountFrom(validUser)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class TlsAuthenticator extends Authenticator {
|
|
92
|
+
constructor (options) {
|
|
93
|
+
super(options)
|
|
94
|
+
this.connection = options.connection
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
static fromParams (req, options) {
|
|
98
|
+
options.connection = req.connection
|
|
99
|
+
return new TlsAuthenticator(options)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
findValidUser () {
|
|
103
|
+
return this.renegotiateTls()
|
|
104
|
+
.then(() => this.getCertificate())
|
|
105
|
+
.then(cert => this.extractWebId(cert))
|
|
106
|
+
.then(webId => this.loadUser(webId))
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
renegotiateTls () {
|
|
110
|
+
const connection = this.connection
|
|
111
|
+
return new Promise((resolve, reject) => {
|
|
112
|
+
connection.renegotiate({ requestCert: true, rejectUnauthorized: false }, (error) => {
|
|
113
|
+
if (error) {
|
|
114
|
+
debug('Error renegotiating TLS:', error)
|
|
115
|
+
return reject(error)
|
|
116
|
+
}
|
|
117
|
+
resolve()
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getCertificate () {
|
|
123
|
+
const certificate = this.connection.getPeerCertificate()
|
|
124
|
+
if (!certificate || !Object.keys(certificate).length) {
|
|
125
|
+
debug('No client certificate detected')
|
|
126
|
+
throw new Error('No client certificate detected. (You may need to restart your browser to retry.)')
|
|
127
|
+
}
|
|
128
|
+
return certificate
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
extractWebId (certificate) {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
this.verifyWebId(certificate, (error, webId) => {
|
|
134
|
+
if (error) {
|
|
135
|
+
debug('Error processing certificate:', error)
|
|
136
|
+
return reject(error)
|
|
137
|
+
}
|
|
138
|
+
resolve(webId)
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
verifyWebId (certificate, callback) {
|
|
144
|
+
debug('Verifying WebID URI')
|
|
145
|
+
webid.verify(certificate, callback)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
discoverProviderFor (webId) {
|
|
149
|
+
return provider.discoverProviderFor(webId)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
loadUser (webId) {
|
|
153
|
+
const serverUri = this.accountManager.host.serverUri
|
|
154
|
+
if (domainMatches(serverUri, webId)) {
|
|
155
|
+
return this.accountManager.userAccountFrom({ webId })
|
|
156
|
+
} else {
|
|
157
|
+
debug(`WebID URI ${JSON.stringify(webId)} is not a local account, using it as an external WebID`)
|
|
158
|
+
return this.accountManager.userAccountFrom({ webId, username: webId, externalWebId: true })
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable no-unused-expressions */
|
|
2
|
+
import { URL } from 'url'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import debug from '../debug.mjs'
|
|
5
|
+
import OidcManager from '@solid/oidc-auth-manager'
|
|
6
|
+
|
|
7
|
+
export function fromServerConfig (argv) {
|
|
8
|
+
const providerUri = argv.host.serverUri
|
|
9
|
+
const authCallbackUri = new URL('/api/oidc/rp', providerUri).toString()
|
|
10
|
+
const postLogoutUri = new URL('/goodbye', providerUri).toString()
|
|
11
|
+
const dbPath = path.join(argv.dbPath, 'oidc')
|
|
12
|
+
const options = {
|
|
13
|
+
debug: debug.authentication,
|
|
14
|
+
providerUri,
|
|
15
|
+
dbPath,
|
|
16
|
+
authCallbackUri,
|
|
17
|
+
postLogoutUri,
|
|
18
|
+
saltRounds: argv.saltRounds,
|
|
19
|
+
delayBeforeRegisteringInitialClient: argv.delayBeforeRegisteringInitialClient,
|
|
20
|
+
host: { debug: debug.authentication }
|
|
21
|
+
}
|
|
22
|
+
return OidcManager.from(options)
|
|
23
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { URL } from 'url'
|
|
2
|
+
import defaults from '../../config/defaults.mjs'
|
|
3
|
+
|
|
4
|
+
class SolidHost {
|
|
5
|
+
constructor (options = {}) {
|
|
6
|
+
this.port = options.port || defaults.port
|
|
7
|
+
this.serverUri = options.serverUri || defaults.serverUri
|
|
8
|
+
this.parsedUri = new URL(this.serverUri)
|
|
9
|
+
this.host = this.parsedUri.host
|
|
10
|
+
this.hostname = this.parsedUri.hostname
|
|
11
|
+
this.live = options.live
|
|
12
|
+
this.root = options.root
|
|
13
|
+
this.multiuser = options.multiuser
|
|
14
|
+
this.webid = options.webid
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static from (options = {}) {
|
|
18
|
+
return new SolidHost(options)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
accountUriFor (accountName) {
|
|
22
|
+
if (!accountName) {
|
|
23
|
+
throw TypeError('Cannot construct uri for blank account name')
|
|
24
|
+
}
|
|
25
|
+
if (!this.parsedUri) {
|
|
26
|
+
throw TypeError('Cannot construct account, host not initialized with serverUri')
|
|
27
|
+
}
|
|
28
|
+
return this.parsedUri.protocol + '//' + accountName + '.' + this.host
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
allowsSessionFor (userId, origin, trustedOrigins) {
|
|
32
|
+
if (!userId || !origin) return true
|
|
33
|
+
const originHost = getHostName(origin)
|
|
34
|
+
const serverHost = getHostName(this.serverUri)
|
|
35
|
+
if (originHost === serverHost) return true
|
|
36
|
+
if (originHost.endsWith('.' + serverHost)) return true
|
|
37
|
+
const userHost = getHostName(userId)
|
|
38
|
+
if (originHost === userHost) return true
|
|
39
|
+
if (trustedOrigins.includes(origin)) return true
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get authEndpoint () {
|
|
44
|
+
const authUrl = new URL('/authorize', this.serverUri)
|
|
45
|
+
// Return the WHATWG URL object
|
|
46
|
+
return authUrl
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
get cookieDomain () {
|
|
50
|
+
let cookieDomain = null
|
|
51
|
+
if (this.hostname.split('.').length > 1) {
|
|
52
|
+
cookieDomain = '.' + this.hostname
|
|
53
|
+
}
|
|
54
|
+
return cookieDomain
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getHostName (urlStr) {
|
|
59
|
+
const match = urlStr.match(/^\w+:\/*([^/]+)/)
|
|
60
|
+
return match ? match[1] : ''
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default SolidHost
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { URL } from 'url'
|
|
2
|
+
|
|
3
|
+
class UserAccount {
|
|
4
|
+
constructor (options = {}) {
|
|
5
|
+
this.username = options.username
|
|
6
|
+
this.webId = options.webId
|
|
7
|
+
this.name = options.name
|
|
8
|
+
this.email = options.email
|
|
9
|
+
this.externalWebId = options.externalWebId
|
|
10
|
+
this.localAccountId = options.localAccountId
|
|
11
|
+
this.idp = options.idp
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static from (options = {}) {
|
|
15
|
+
return new UserAccount(options)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get displayName () {
|
|
19
|
+
return this.name || this.username || this.email || 'Solid account'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get id () {
|
|
23
|
+
if (!this.webId) { return null }
|
|
24
|
+
const parsed = new URL(this.webId)
|
|
25
|
+
let id = parsed.host + parsed.pathname
|
|
26
|
+
if (parsed.hash) {
|
|
27
|
+
id += parsed.hash
|
|
28
|
+
}
|
|
29
|
+
return id
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get accountUri () {
|
|
33
|
+
if (!this.webId) { return null }
|
|
34
|
+
const parsed = new URL(this.webId)
|
|
35
|
+
return parsed.origin
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get podUri () {
|
|
39
|
+
const webIdUrl = new URL(this.webId)
|
|
40
|
+
return webIdUrl.origin
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
get profileUri () {
|
|
44
|
+
if (!this.webId) { return null }
|
|
45
|
+
const parsed = new URL(this.webId)
|
|
46
|
+
return parsed.origin + parsed.pathname
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default UserAccount
|