Skip to content

Commit

Permalink
formatting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinash Gusain committed Oct 31, 2023
1 parent b03f922 commit d1572c3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
21 changes: 11 additions & 10 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function boot(IBootContext $context): void
$request = $container->get(IRequest::class);
$bearerAuthBackend = $container->query(BearerAuthBackend::class);

// If it is an OCS request, try to authenticate with bearer token
if ($request->getHeader('OCS-APIREQUEST') === 'true' &&
$request->getHeader('OIDC-LOGIN-WITH-TOKEN') === 'true' &&
str_starts_with($request->getHeader('Authorization'), 'Bearer ')) {
// If it is an OCS request, try to authenticate with bearer token
if ($request->getHeader('OCS-APIREQUEST') === 'true' &&
$request->getHeader('OIDC-LOGIN-WITH-TOKEN') === 'true' &&
str_starts_with($request->getHeader('Authorization'), 'Bearer ')) {
$this->loginWithBearerToken($request, $bearerAuthBackend);
}

Expand All @@ -84,7 +84,7 @@ public function boot(IBootContext $context): void
$altLoginPage = $this->config->getSystemValue('oidc_login_alt_login_page', false);

// URL for login without redirecting forcefully, false if we are not doing that
$noRedirLoginUrl = $useLoginRedirect ? $this->url->linkToRouteAbsolute('core.login.showLoginForm').'?noredir=1' : false;
$noRedirLoginUrl = $useLoginRedirect ? $this->url->linkToRouteAbsolute('core.login.showLoginForm') . '?noredir=1' : false;

// Get logged in user's session
$userSession = $container->get(IUserSession::class);
Expand Down Expand Up @@ -115,7 +115,7 @@ public function boot(IBootContext $context): void
$session->close();
header('Clear-Site-Data: "cache", "storage"');

header('Location: '.$logoutUrl);
header('Location: ' . $logoutUrl);

exit;
});
Expand Down Expand Up @@ -149,7 +149,7 @@ public function boot(IBootContext $context): void

// Force redirect
if ($useLoginRedirect) {
header('Location: '.$loginLink);
header('Location: ' . $loginLink);

exit;
}
Expand All @@ -166,12 +166,13 @@ public function boot(IBootContext $context): void
}
}

private function loginWithBearerToken(IRequest $request, BearerAuthBackend $bearerAuthBackend) {
private function loginWithBearerToken(IRequest $request, BearerAuthBackend $bearerAuthBackend)
{
$authHeader = $request->getHeader('Authorization');
$bearerToken = substr($authHeader, 7);
$bearerToken = substr($authHeader, 7);
if (empty($bearerToken)) {
return;
}
$bearerAuthBackend->validateBearerToken($bearerToken);
$bearerAuthBackend->validateBearerToken($bearerToken);
}
}
4 changes: 1 addition & 3 deletions lib/OIDCLoginOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,5 @@ public function getClass(): string
return 'oidc-button';
}

public function load(): void
{
}
public function load(): void {}
}
10 changes: 5 additions & 5 deletions lib/Service/LoginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ private function getLoginFilterValues(array $profile): array

// Make sure login filter allowed values names is an array
if (!\is_array($profileLoginFilterValues)) {
throw new LoginException('Login filter values field must be an array, '.\gettype($profileLoginFilterValues).' given');
throw new LoginException('Login filter values field must be an array, ' . \gettype($profileLoginFilterValues) . ' given');
}

// Add to all login filter values
Expand Down Expand Up @@ -459,7 +459,7 @@ private function getGroupNames(array $profile)

// Make sure group names is an array
if (!\is_array($profileGroups)) {
throw new LoginException('Groups field must be an array, '.\gettype($profileGroups).' given');
throw new LoginException('Groups field must be an array, ' . \gettype($profileGroups) . ' given');
}

// Add to all groups
Expand Down Expand Up @@ -518,12 +518,12 @@ private function flatten(array $array, string $prefix = ''): array
{
$result = [];
foreach ($array as $key => $value) {
$result[$prefix.$key] = $value;
$result[$prefix . $key] = $value;
if (\is_array($value)) {
$result = $result + $this->flatten($value, $prefix.$key.'_');
$result = $result + $this->flatten($value, $prefix . $key . '_');
}
if (\is_int($key) && \is_string($value)) {
$result[$prefix.$value] = $value;
$result[$prefix . $value] = $value;
}
}

Expand Down

0 comments on commit d1572c3

Please sign in to comment.