4 * Authorization Server Member
7 * @link http://www.open-emr.org
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @copyright Copyright (c) 2020 Jerry Padgett <sjpadgett@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 namespace OpenEMR\Common\Auth\OpenIDConnect\Entities
;
15 use League\OAuth2\Server\Entities\ClientEntityInterface
;
16 use League\OAuth2\Server\Entities\Traits\ClientTrait
;
17 use League\OAuth2\Server\Entities\Traits\EntityTrait
;
19 class ClientEntity
implements ClientEntityInterface
25 protected $clientRole;
34 * Confidential apps or apps with a 'launch' scope must be manually authorized by an adminstrator before their
41 * @var array[] Array of trusted user objects
43 protected $trustedUsers;
46 * @var string[] The list of contact email addresses to reach out for questions about the client app
51 * @var string The logout uri to send users to to logout from the application.
53 protected $logoutRedirectUris;
55 protected $registrationDate;
57 public function __construct()
62 public function setName($name): void
67 public function setRedirectUri($uri): void
69 if (\
is_string($uri)) {
70 $this->redirectUri
= [$uri];
71 } else if (\
is_array($uri)) {
72 $this->redirectUri
= $uri;
74 throw new \
InvalidArgumentException("redirectUri must be a string or array");
78 public function setIsConfidential($set): void
80 $this->isConfidential
= $set;
83 public function setIsEnabled($set): void
85 $this->isEnabled
= $set === 1 ||
$set === true;
88 public function isEnabled(): bool
90 return $this->isEnabled
;
93 public function setUserId($id): void
98 public function getUserId()
100 return $this->userId
;
103 public function setClientRole($role): void
105 $this->clientRole
= $role;
108 public function getClientRole()
110 return $this->clientRole
;
113 public function getScopes()
115 return $this->scopes
;
117 public function setScopes($scopes)
119 // clear out the scopes if our scopes are empty
120 if (empty($scopes)) {
125 if (is_string($scopes)) {
126 $scopes = explode(" ", $scopes);
127 } else if (!is_array($scopes)) {
128 throw new \
InvalidArgumentException("scopes parameter must be a valid array or string");
130 $this->scopes
= $scopes;
134 * Checks if a given entity
138 public function hasScope($scope)
140 return in_array($scope, $this->scopes
);
144 * Returns the registered launch URI (as a string).
146 * @params $launchParams string A URL query string params to append to the launch uri.
149 public function getLaunchUri($launchParams = '')
151 $launchParams = isset($launchParams) ?
$launchParams : '';
152 return $this->launchUri
. $launchParams;
155 public function setLaunchUri($uri): void
157 $this->launchUri
= $uri;
163 public function getJwks()
171 public function getJwksUri()
173 return $this->jwksUri
;
177 * @param string $jwks
179 public function setJwks($jwks): void
185 * @param string $jwksUri
187 public function setJwksUri($jwksUri): void
189 $this->jwksUri
= $jwksUri;
193 * Array of records from the oauth2_trusted_users table
196 public function getTrustedUsers(): array
198 return $this->trustedUsers
;
202 * Set the trusted user records (these come from the oauth2_trusted_users table
203 * @param array $trustedUsers
205 public function setTrustedUsers(array $trustedUsers)
207 $this->trustedUsers
= $trustedUsers;
210 public function getContacts()
212 return $this->contacts
;
215 public function setContacts($contacts)
217 $this->contacts
= $contacts;
220 public function setRegistrationDate($registerDate)
222 $this->registrationDate
= $registerDate;
225 public function getRegistrationDate()
227 return $this->registrationDate
;
233 public function getLogoutRedirectUris(): string
235 return $this->logoutRedirectUris
;
239 * @param string $logoutRedirectUris
241 public function setLogoutRedirectUris(?
string $logoutRedirectUris): void
243 $this->logoutRedirectUris
= $logoutRedirectUris;