mirror of
http://124.126.16.154:8888/singularity/hyperf-saml.git
synced 2026-01-15 07:15:05 +08:00
fix(sso): User类的使用问题造成的响应格式错误
Signed-off-by: 李东云 <dongyun.li@luxcreo.ai>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
* Created on 2022/3/29
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace Singularity\HyperfSaml\Services\Sp;
|
||||
|
||||
use Exception;
|
||||
@@ -77,9 +78,9 @@ class Assertion
|
||||
*
|
||||
* @param \LightSaml\Model\Protocol\Response $response
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\Singularity\HDK\Account\Resource\User
|
||||
* @return array|\Psr\Http\Message\ResponseInterface|\Singularity\HDK\Account\Resource\User
|
||||
*/
|
||||
public function consumeResponse(Response $response): \Psr\Http\Message\ResponseInterface|User
|
||||
public function consumeResponse(Response $response): array|\Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
$allow_multi_online = config('saml.allow_multi_online');
|
||||
$redis_prefix = config('common.redis.prefix');
|
||||
@@ -88,14 +89,13 @@ class Assertion
|
||||
$user = $this->base->getAllAttributes($response);
|
||||
|
||||
$user = array_replace($oldUser?->toArray() ?? [], $user->toArray());
|
||||
$user = new User($user);
|
||||
|
||||
|
||||
// 更新
|
||||
$token = $this->authentication->generate($user);
|
||||
$token = $this->authentication->generate(new User($user));
|
||||
// 记录映射
|
||||
$key = "{$redis_prefix}user:token_map:{$user['uid']}";
|
||||
if ($allow_multi_online) {
|
||||
$this->redis->hSet($key, $user->originToken, $token);
|
||||
$this->redis->hSet($key, $user['originToken'], $token);
|
||||
} else {
|
||||
$this->redis->set($key, $token);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user