diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2019-04-27 10:58:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 10:58:26 +0200 |
commit | ea54c2adb126a77c244c30059c40149754d4dbb7 (patch) | |
tree | 7f9fee18f321bef35ed845ce0f921dab2bddc72b /src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | |
parent | bfd69c74e5b4f2ebfcb304b1983bf771c2bb11f7 (diff) | |
parent | 35359bd3c67e5b6c6371e2e547a3411ca0a8027b (diff) | |
download | wallabag-ea54c2adb126a77c244c30059c40149754d4dbb7.tar.gz wallabag-ea54c2adb126a77c244c30059c40149754d4dbb7.tar.zst wallabag-ea54c2adb126a77c244c30059c40149754d4dbb7.zip |
Merge pull request #3937 from wallabag/fix/credential-subdomain
Add ability to match many domains for credentials
Diffstat (limited to 'src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php')
-rw-r--r-- | src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php index 90e00c62..c7502bac 100644 --- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php +++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | |||
@@ -62,11 +62,24 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder | |||
62 | $host = substr($host, 4); | 62 | $host = substr($host, 4); |
63 | } | 63 | } |
64 | 64 | ||
65 | $credentials = null; | 65 | if (!$this->currentUser) { |
66 | if ($this->currentUser) { | 66 | $this->logger->debug('Auth: no current user defined.'); |
67 | $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); | 67 | |
68 | return false; | ||
69 | } | ||
70 | |||
71 | $hosts = [$host]; | ||
72 | // will try to see for a host without the first subdomain (fr.example.org & .example.org) | ||
73 | $split = explode('.', $host); | ||
74 | |||
75 | if (\count($split) > 1) { | ||
76 | // remove first subdomain | ||
77 | array_shift($split); | ||
78 | $hosts[] = '.' . implode('.', $split); | ||
68 | } | 79 | } |
69 | 80 | ||
81 | $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId()); | ||
82 | |||
70 | if (null === $credentials) { | 83 | if (null === $credentials) { |
71 | $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); | 84 | $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); |
72 | 85 | ||