diff --git a/src/Factory/ServiceAuthorizationRepositoryFactory.php b/src/Factory/ServiceAuthorizationRepositoryFactory.php new file mode 100644 index 00000000..71ddee87 --- /dev/null +++ b/src/Factory/ServiceAuthorizationRepositoryFactory.php @@ -0,0 +1,18 @@ +userId; + } + + public function providerId(): string + { + return $this->providerId; + } + + public function grant(): ?TokenGrant + { + return $this->grant; + } +} diff --git a/src/Service/GrantStrategy.php b/src/Service/GrantStrategy.php new file mode 100644 index 00000000..8c5ae703 --- /dev/null +++ b/src/Service/GrantStrategy.php @@ -0,0 +1,22 @@ +getAccessToken(). + * + * @throws ServiceNotAuthorizedException when !isSatisfied() + * @throws OAuthTokenRefreshException when the grant refresh fails + */ + public function getAccessToken(): string; +} diff --git a/src/Service/ServiceAuthorizationRepository.php b/src/Service/ServiceAuthorizationRepository.php new file mode 100644 index 00000000..4f3f943a --- /dev/null +++ b/src/Service/ServiceAuthorizationRepository.php @@ -0,0 +1,26 @@ +identifier(), + $providerId + ); + } + parent::__construct($message, $code, $previous); + } + + public function userId(): string + { + return $this->userId; + } + + public function providerId(): string + { + return $this->providerId; + } + + public function purpose(): ServicePurpose + { + return $this->purpose; + } + + /** Scopes still needed; empty ScopeSet if no grant exists at all. */ + public function missingScopes(): ScopeSet + { + return $this->missingScopes; + } +} diff --git a/src/Service/ServicePurpose.php b/src/Service/ServicePurpose.php new file mode 100644 index 00000000..006aa196 --- /dev/null +++ b/src/Service/ServicePurpose.php @@ -0,0 +1,50 @@ +identifier; + } + + public function grantStrategy(): GrantStrategy + { + return $this->grantStrategy; + } + + public function equals(self $other): bool + { + return $this->identifier === $other->identifier; + } + + /** Round-trip through OAuthFlowData persistence. */ + public function serialize(): array + { + return ['id' => $this->identifier, 'strategy' => $this->grantStrategy->value]; + } + + public static function deserialize(array $data): self + { + return new self($data['id'], GrantStrategy::from($data['strategy'])); + } +} diff --git a/src/Service/TokenGrant.php b/src/Service/TokenGrant.php new file mode 100644 index 00000000..3d1558fe --- /dev/null +++ b/src/Service/TokenGrant.php @@ -0,0 +1,36 @@ +identifier() + ); + } + parent::__construct($message, $code, $previous); + } + + public function providerId(): string + { + return $this->providerId; + } + + public function purpose(): ServicePurpose + { + return $this->purpose; + } +}