Skip to content

Commit 9b2c3e0

Browse files
committed
removed hardcoded url, use SERVER_ROOT env variable now
updated to use env USERNAME instead of USER
1 parent 775cfd4 commit 9b2c3e0

4 files changed

Lines changed: 22 additions & 17 deletions

File tree

src/Controller/AuthorizeController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
1414
$response = $response->withStatus(302, "Approval required");
1515

1616
// FIXME: Generate a proper url for this;
17-
$loginUrl = "https://localhost/login/?returnUrl=" . urlencode($_SERVER['REQUEST_URI']);
17+
$baseUrl = $this->baseUrl;
18+
$loginUrl = $baseUrl . "/login/?returnUrl=" . urlencode($_SERVER['REQUEST_URI']);
1819
$response = $response->withHeader("Location", $loginUrl);
1920
return $response;
2021
}
@@ -50,7 +51,8 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
5051
$response = $response->withStatus(302, "Approval required");
5152

5253
// FIXME: Generate a proper url for this;
53-
$approvalUrl = "https://localhost/sharing/$clientId/?returnUrl=" . urlencode($_SERVER['REQUEST_URI']);
54+
$baseUrl = $this->baseUrl;
55+
$approvalUrl = $baseUrl . "/sharing/$clientId/?returnUrl=" . urlencode($_SERVER['REQUEST_URI']);
5456
$response = $response->withHeader("Location", $approvalUrl);
5557
return $response;
5658
}

src/Controller/LoginController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
2222
}
2323
$response->getBody()->write("<h1>Already logged in as $user</h1>");
2424
} else if (
25-
($postBody['username'] == $_ENV['USER'] && $postBody['password'] == $_ENV['PASSWORD']) ||
26-
($postBody['username'] == $_SERVER['USER'] && $postBody['password'] == $_SERVER['PASSWORD'])
25+
($postBody['username'] == $_ENV['USERNAME'] && $postBody['password'] == $_ENV['PASSWORD']) ||
26+
($postBody['username'] == $_SERVER['USERNAME'] && $postBody['password'] == $_SERVER['PASSWORD'])
2727
) {
2828
$user = $postBody['username'];
2929
$_SESSION['userid'] = $user;

src/Controller/RegisterController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ final public function __invoke(ServerRequestInterface $request, array $args): Re
2020
$origin = $parsedOrigin['host'];
2121

2222
$clientId = $this->config->saveClientRegistration($origin, $clientData);
23-
23+
24+
// FIXME: properly generate this url;
25+
$baseUrl = $this->baseUrl;
26+
$clientUrl = $baseUrl . "/clients/$clientId";
27+
2428
$registration = array(
2529
'client_id' => $clientId,
26-
'registration_client_uri' => "https://localhost/clients/$clientId", // FIXME: properly generate this url;
30+
'registration_client_uri' => $clientUrl,
2731
'client_id_issued_at' => $clientData['client_id_issued_at'],
2832
'redirect_uris' => $clientData['redirect_uris'],
2933
);

src/Controller/ServerController.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,21 @@ public function __construct() {
2020
$this->authServerConfig = $this->createAuthServerConfig();
2121
$this->authServerFactory = (new \Pdsinterop\Solid\Auth\Factory\AuthorizationServerFactory($this->authServerConfig))->create();
2222
$this->tokenGenerator = (new \Pdsinterop\Solid\Auth\TokenGenerator($this->authServerConfig));
23-
24-
// $this->baseUrl = "https://localhost";
23+
$this->baseUrl = isset($_ENV['SERVER_ROOT']) ? $_ENV['SERVER_ROOT'] : "https://localhost";
2524
}
2625

2726
public function getOpenIdEndpoints() {
2827
// FIXME: would be better to base this on the available routes if possible.
29-
$this->baseUrl = "https://server/"; // FIXME: generate proper urls
28+
$this->baseUrl = isset($_ENV['SERVER_ROOT']) ? $_ENV['SERVER_ROOT'] : "https://localhost";
3029
return [
3130
'issuer' => $this->baseUrl,
32-
'authorization_endpoint' => $this->baseUrl . "authorize",
33-
'jwks_uri' => $this->baseUrl . "jwks",
34-
"check_session_iframe" => $this->baseUrl . "session",
35-
"end_session_endpoint" => $this->baseUrl . "logout",
36-
"token_endpoint" => $this->baseUrl . "token",
37-
"userinfo_endpoint" => $this->baseUrl . "userinfo",
38-
"registration_endpoint" => $this->baseUrl . "register"
31+
'authorization_endpoint' => $this->baseUrl . "/authorize",
32+
'jwks_uri' => $this->baseUrl . "/jwks",
33+
"check_session_iframe" => $this->baseUrl . "/session",
34+
"end_session_endpoint" => $this->baseUrl . "/logout",
35+
"token_endpoint" => $this->baseUrl . "/token",
36+
"userinfo_endpoint" => $this->baseUrl . "/userinfo",
37+
"registration_endpoint" => $this->baseUrl . "/register",
3938
];
4039
}
4140

@@ -114,7 +113,7 @@ public function checkApproval($clientId) {
114113
}
115114

116115
public function getProfilePage() {
117-
return $this->baseUrl . "profile/card#me"; // FIXME: would be better to base this on the available routes if possible.
116+
return $this->baseUrl . "/profile/card#me"; // FIXME: would be better to base this on the available routes if possible.
118117
}
119118

120119
public function getResponseType() {

0 commit comments

Comments
 (0)