Skip to content

Commit fd20e41

Browse files
committed
start of user-specific subdomains support
1 parent a6556c6 commit fd20e41

9 files changed

Lines changed: 103 additions & 8 deletions

File tree

docker-compose-dev.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
db:
3+
environment:
4+
MYSQL_DATABASE: nextcloud
5+
MYSQL_PASSWORD: nextcloud
6+
MYSQL_ROOT_PASSWORD: root
7+
MYSQL_USER: nextcloud
8+
image: mysql:8.0.32
9+
ports:
10+
- "3306:3306"
11+
# To start with a populated database, mount an SQL file
12+
# volumes:
13+
# - ./init.sql:/docker-entrypoint-initdb.d/init.sql
14+
15+
nextcloud:
16+
depends_on:
17+
- db
18+
environment:
19+
- MARIADB_ROOT_PASSWORD=nextcloud
20+
- MYSQL_HOST=db
21+
expose:
22+
- 443
23+
image: ghcr.io/pdsinterop/solid-nextcloud:main-30
24+
ports:
25+
- "443:443"
26+
volumes:
27+
- ./solid/:/var/www/html/apps/solid/
28+
- ./site.conf:/etc/apache2/sites-enabled/000-default.conf
29+
30+
pubsub:
31+
depends_on:
32+
- nextcloud
33+
expose:
34+
- 8080
35+
image: ghcr.io/pdsinterop/php-solid-pubsub-server
36+
ports:
37+
- "8080:8080"

solid/css/settings-admin.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#solid-admin label {
1+
#solid-admin label.narrow {
22
width: 160px;
33
vertical-align: top;
44
display: block;
@@ -8,4 +8,8 @@
88
height: 240px;
99
font-size: 12px;
1010
font-family: monospace;
11+
}
12+
#solid-admin input.textaligned {
13+
height: 1rem;
14+
min-height: unset;
1115
}

solid/lib/Controller/AppController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ class AppController extends Controller {
2020
private $urlGenerator;
2121
private $config;
2222

23-
public function __construct($AppName, IRequest $request, IConfig $config, IUserManager $userManager, IManager $contactsManager, IURLGenerator $urlGenerator, $userId){
23+
public function __construct($AppName, IRequest $request, IConfig $config, IUserManager $userManager, IManager $contactsManager, IURLGenerator $urlGenerator, $userId
24+
// , bool $userDomains
25+
){
2426
parent::__construct($AppName, $request);
2527
$this->userId = $userId;
2628
$this->userManager = $userManager;
2729
$this->contactsManager = $contactsManager;
2830
$this->request = $request;
2931
$this->urlGenerator = $urlGenerator;
3032
$this->config = new \OCA\Solid\ServerConfig($config, $urlGenerator, $userManager);
33+
// $this->userDomains = $userDomains;
3134
}
3235

3336
private function getUserApps($userId) {
@@ -67,6 +70,9 @@ private function getProfilePage() {
6770
private function getStorageUrl($userId) {
6871
$storageUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute("solid.storage.handleHead", array("userId" => $userId, "path" => "foo")));
6972
$storageUrl = preg_replace('/foo$/', '', $storageUrl);
73+
// if ($this->userDomains) {
74+
$storageUrl = $userId.'.'.$storageUrl;
75+
// }
7076
return $storageUrl;
7177
}
7278
/**

solid/lib/Controller/ProfileController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,24 @@ private function getProfileUrl($userId) {
131131
$profileUrl = preg_replace('/foo$/', '', $profileUrl);
132132
return $profileUrl;
133133
}
134+
135+
private function build_url(array $parts) {
136+
return (isset($parts['scheme']) ? "{$parts['scheme']}:" : '') .
137+
(isset($parts['host']) ? "//{$parts['host']}" : '') .
138+
(isset($parts['port']) ? ":{$parts['port']}" : '') .
139+
(isset($parts['path']) ? "{$parts['path']}" : '') .
140+
(isset($parts['query']) ? "?{$parts['query']}" : '') .
141+
(isset($parts['fragment']) ? "#{$parts['fragment']}" : '');
142+
}
143+
134144
private function getStorageUrl($userId) {
135145
$storageUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute("solid.storage.handleHead", array("userId" => $userId, "path" => "foo")));
136146
$storageUrl = preg_replace('/foo$/', '/', $storageUrl);
147+
// if ($this->userDomains) {
148+
$url = parse_url($storageUrl);
149+
$url['host'] = $userId.'.'.$url['host'];
150+
$storageUrl = $this->build_url($url);
151+
// }
137152
return $storageUrl;
138153
}
139154

@@ -190,6 +205,7 @@ public function handleRequest($userId, $path) {
190205
* @NoCSRFRequired
191206
*/
192207
public function handleGet($userId, $path) {
208+
//TODO: check that the $userId matches the userDomain, if enabled.
193209
return $this->handleRequest($userId, $path);
194210
}
195211

@@ -287,6 +303,7 @@ private function getUserProfile($userId) {
287303
}
288304
}
289305
}
306+
//TODO: privateTypeIndex and publisTypeIndex need to user getStorageURL
290307
if ($user !== null) {
291308
$profile = array(
292309
'id' => $userId,

solid/lib/Controller/StorageController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ private function getUserProfile($userId) {
9393
private function getStorageUrl($userId) {
9494
$storageUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute("solid.storage.handleHead", array("userId" => $userId, "path" => "foo")));
9595
$storageUrl = preg_replace('/foo$/', '', $storageUrl);
96+
// if ($this->userDomains) {
97+
$storageUrl = $userId.'.'.$storageUrl;
98+
// }
9699
return $storageUrl;
97100
}
101+
98102
private function generateDefaultAcl($userId) {
99103
$defaultAcl = <<< EOF
100104
# Root ACL resource for the user account

solid/lib/Sections/SolidAdmin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ public function getName(): string {
2929
public function getPriority(): int {
3030
return 98;
3131
}
32+
3233
}

solid/lib/ServerConfig.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ class ServerConfig extends BaseServerConfig {
1313
private IConfig $config;
1414
private IUrlGenerator $urlGenerator;
1515
private IUserManager $userManager;
16+
// private bool $userDomains;
1617

1718
/**
1819
* @param IConfig $config
1920
* @param IUrlGenerator $urlGenerator
2021
* @param IUserManager $userManager
22+
* @param bool $userDomains
2123
*/
22-
public function __construct(IConfig $config, IUrlGenerator $urlGenerator, IUserManager $userManager) {
24+
public function __construct(IConfig $config, IUrlGenerator $urlGenerator, IUserManager $userManager
25+
// , bool $userDomains
26+
) {
2327
$this->config = $config;
2428
$this->userManager = $userManager;
2529
$this->urlGenerator = $urlGenerator;
30+
// $this->userDomains = $userDomains;
2631
parent::__construct($config);
2732
}
2833

@@ -62,4 +67,11 @@ public function setProfileData($userId, $profileData) {
6267
$user->setDisplayName($fields['name']);
6368
}
6469
}
70+
// public function getUserDomains() {
71+
// return $this->userDomains;
72+
// }
73+
// public function setUserDomains($userDomains) {
74+
// $this->userDomains = $userDomains;
75+
// }
76+
6577
}

solid/lib/Settings/SolidAdmin.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ class SolidAdmin implements ISettings {
1111
private IL10N $l;
1212
private IConfig $config;
1313
private BaseServerConfig $serverConfig;
14+
// private Bool $userDomains;
1415

15-
public function __construct(IConfig $config, IL10N $l) {
16+
public function __construct(IConfig $config, IL10N $l
17+
// , bool $userDomains
18+
) {
1619
$this->config = $config;
1720
$this->l = $l;
1821
$this->serverConfig = new BaseServerConfig($config);
22+
// $this->userDomains = $userDomains;
1923
}
2024

2125
/**
@@ -26,8 +30,9 @@ public function getForm() {
2630

2731
$parameters = [
2832
'privateKey' => $this->serverConfig->getPrivateKey(),
29-
'encryptionKey' => $this->serverConfig->getEncryptionKey(),
30-
'clients' => $allClients
33+
'encryptionKey' => $this->serverConfig->getEncryptionKey(),
34+
'clients' => $allClients,
35+
// 'userDomains' => (int) $this->userDomains
3136
];
3237

3338
return new TemplateResponse('solid', 'admin', $parameters, '');

solid/templates/admin.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66
?>
77

88
<div id="solid-admin" class="section">
9-
<h2 class="inlineblock"><?php p($l->t('Solid OpenID Connect Settings')); ?></h2>
9+
<h2 class="inlineblock"><?php p($l->t('Solid Server Settings')); ?></h2>
1010
<p>
1111
<label>
12+
<input type="checkbox" id="solid-user-subdomains" class="textaligned" value="1" <?php if ($_['userDomains']); ?> checked="checked" <?php endif; ?>>
13+
<span><?php p($l->t('Enable User Subdomains')); ?></span>
14+
</label>
15+
</p>
16+
17+
<h2 class="inlineblock"><?php p($l->t('Solid OpenID Connect Settings')); ?></h2>
18+
<p>
19+
<label class="narrow">
1220
<span><?php p($l->t('Private Key')); ?></span>
1321
<textarea id="solid-private-key" type="text"><?php p($_['privateKey']); ?></textarea>
1422
</label>
1523

16-
<label>
24+
<label class="narrow">
1725
<span><?php p($l->t('Encryption Key')); ?></span>
1826
<textarea id="solid-encryption-key" type="text"><?php p($_['encryptionKey']); ?></textarea>
1927
</label>
@@ -37,4 +45,5 @@
3745
<?php } ?>
3846
</tbody>
3947
</table>
48+
4049
</div>

0 commit comments

Comments
 (0)