Skip to content

Commit

Permalink
Merge pull request #92 from vcg-development/feat-user
Browse files Browse the repository at this point in the history
Add `user` option to `Redis` adapter to authenticate with a specific user
  • Loading branch information
boesing committed May 21, 2024
2 parents 82c636c + b5f57c8 commit 3b234a8
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 272 deletions.
108 changes: 1 addition & 107 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
</PossiblyNullReference>
<PossiblyUnusedReturnValue>
<code>Redis</code>
<code>bool</code>
</PossiblyUnusedReturnValue>
<PropertyNotSetInConstructor>
<code>Redis</code>
Expand Down Expand Up @@ -138,17 +137,11 @@
<code>setPersistent</code>
<code>setReadTimeout</code>
<code>setSeeds</code>
<code>setTimeout</code>
<code>setSslContext</code>
<code>setTimeout</code>
</PossiblyUnusedMethod>
</file>
<file src="src/RedisOptions.php">
<InvalidReturnStatement>
<code><![CDATA[$this->getResourceManager()->getDatabase($this->getResourceId())]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code>int</code>
</InvalidReturnType>
<LessSpecificReturnStatement>
<code>parent::setNamespace($namespace)</code>
</LessSpecificReturnStatement>
Expand All @@ -169,13 +162,8 @@
</DocblockTypeContradiction>
<InvalidReturnStatement>
<code>$info</code>
<code>$this</code>
<code><![CDATA[$this->setResource($id, [
'password' => $password,
])]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code>RedisResource</code>
<code>array{redis_version:string}</code>
</InvalidReturnType>
<MissingReturnType>
Expand All @@ -185,94 +173,8 @@
<code>normalizeServer</code>
</MissingReturnType>
<MixedArgument>
<code>$k</code>
<code>$key</code>
<code>$resource</code>
<code><![CDATA[$resource['database']]]></code>
<code><![CDATA[$resource['lib_options']]]></code>
<code><![CDATA[$resource['persistent_id']]]></code>
<code><![CDATA[$resource['persistent_id']]]></code>
<code><![CDATA[$resource['server']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['port']]]></code>
<code><![CDATA[$server['port']]]></code>
<code><![CDATA[$server['timeout']]]></code>
<code><![CDATA[$server['timeout']]]></code>
<code><![CDATA[$server['timeout']]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$resource['database']]]></code>
<code><![CDATA[$resource['initialized']]]></code>
<code><![CDATA[$resource['initialized']]]></code>
<code><![CDATA[$resource['initialized']]]></code>
<code><![CDATA[$resource['lib_options']]]></code>
<code><![CDATA[$resource['lib_options']]]></code>
<code><![CDATA[$resource['lib_options'][$key]]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['persistent_id']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['server']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['host']]]></code>
<code><![CDATA[$server['port']]]></code>
<code><![CDATA[$server['port']]]></code>
<code><![CDATA[$server['timeout']]]></code>
<code><![CDATA[$server['timeout']]]></code>
<code><![CDATA[$server['timeout']]]></code>
<code><![CDATA[$this->resources[$resourceId]['version']]]></code>
<code><![CDATA[$this->resources[$resourceId]['version']]]></code>
</MixedArrayAccess>
<MixedArrayAssignment>
<code><![CDATA[$resource['database']]]></code>
<code><![CDATA[$resource['initialized']]]></code>
<code><![CDATA[$resource['lib_options']]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['persistent_id']]]></code>
<code><![CDATA[$resource['server']]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code>$libOptions[$constValue]</code>
</MixedArrayOffset>
<MixedInferredReturnType>
<code>RedisResource</code>
<code>array</code>
<code>array</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string</code>
<code>string|null</code>
</MixedInferredReturnType>
<MixedMethodCall>
<code>getOption</code>
<code>getOption</code>
</MixedMethodCall>
<MixedReturnStatement>
<code><![CDATA[$resource['database']]]></code>
<code><![CDATA[$resource['lib_options']]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['password']]]></code>
<code><![CDATA[$resource['persistent_id']]]></code>
<code><![CDATA[$resource['resource']]]></code>
<code><![CDATA[$resource['server']]]></code>
<code><![CDATA[$this->resources[$resourceId]['version']]]></code>
</MixedReturnStatement>
<NoValue>
<code>$server</code>
</NoValue>
Expand All @@ -299,7 +201,6 @@
<code><![CDATA[$resource = &$this->resources[$id]]]></code>
<code><![CDATA[$resource = &$this->resources[$id]]]></code>
<code><![CDATA[$resource = &$this->resources[$id]]]></code>
<code><![CDATA[$resource = &$this->resources[$id]]]></code>
</UnsupportedPropertyReferenceUsage>
</file>
<file src="test/integration/Laminas/RedisFromExtensionAsset.php">
Expand All @@ -316,13 +217,6 @@
<code><![CDATA[$this->storage->getMetadata($key)['ttl']]]></code>
<code><![CDATA[$this->storage->getMetadata($key)['ttl']]]></code>
</PossiblyInvalidArrayAccess>
<PossiblyNullPropertyAssignmentValue>
<code>null</code>
<code>null</code>
</PossiblyNullPropertyAssignmentValue>
<RedundantConditionGivenDocblockType>
<code><![CDATA[$this->storage]]></code>
</RedundantConditionGivenDocblockType>
<UndefinedMethod>
<code><![CDATA[$redis->info()]]></code>
</UndefinedMethod>
Expand Down
23 changes: 21 additions & 2 deletions src/RedisOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Laminas\Cache\Storage\Adapter;

use Laminas\Cache\Exception;
use Laminas\Cache\Storage\Adapter\RedisResourceManager;

use function sprintf;
use function strlen;
Expand Down Expand Up @@ -255,10 +254,30 @@ public function setPassword($password)
/**
* Get resource password
*
* @return string
* @return string|null
*/
public function getPassword()
{
return $this->getResourceManager()->getPassword($this->getResourceId());
}

/**
* Set resource user
*
* @param string $user ACL User
* @return RedisOptions Provides a fluent interface
*/
public function setUser(string $user): RedisOptions
{
$this->getResourceManager()->setUser($this->getResourceId(), $user);
return $this;
}

/**
* Get resource user
*/
public function getUser(): ?string
{
return $this->getResourceManager()->getUser($this->getResourceId());
}
}
Loading

0 comments on commit 3b234a8

Please sign in to comment.