8000 feature #37318 [Security] Add attributes on Passport (fabpot) · symfony/symfony@3267e8e · GitHub
[go: up one dir, main page]

Skip to content

Commit 3267e8e

Browse files
committed
feature #37318 [Security] Add attributes on Passport (fabpot)
This PR was merged into the 5.2-dev branch. Discussion ---------- [Security] Add attributes on Passport | Q | A | ------------- | --- | Branch? | master <!-- see below --> | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | n/a <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | not yet see symfonycorp/connect#95 /cc @wouterj Commits ------- 440ada3 [Security] Add attributes on Passport
2 parents 6ad781c + 440ada3 commit 3267e8e

File tree

1 file changed

+21
-1
lines changed
  • src/Symfony/Component/Security/Http/Authenticator/Passport

1 file changed

+21
-1
lines changed

src/Symfony/Component/Security/Http/Authenticator/Passport/Passport.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ class Passport implements UserPassportInterface
2828

2929
protected $user;
3030

31+
private $attributes = [];
32+
3133
/**
3234
* @param CredentialsInterface $credentials the credentials to check for this authentication, use
33-
* SelfValidatingPassport if no credentials should be checked.
35+
* SelfValidatingPassport if no credentials should be checked
3436
* @param BadgeInterface[] $badges
3537
*/
3638
public function __construct(UserInterface $user, CredentialsInterface $credentials, array $badges = [])
@@ -47,4 +49,22 @@ public function getUser(): UserInterface
4749
{
4850
return $this->user;
4951
}
52+
53+
/**
54+
* @param mixed $value
55+
*/
56+
public function setAttribute(string $name, $value): void
57+
{
58+
$this->attributes[$name] = $value;
59+
}
60+
61+
/**
62+
* @param mixed $default
63+
*
64+
* @return mixed
65+
*/
66+
public function getAttribute(string $name, $default = null)
67+
{
68+
return $this->attributes[$name] ?? $default;
69+
}
5070
}

0 commit comments

Comments
 (0)
0