_authServer === null) { $clientsRepo = new Repositories\ClientRepository(); $accessTokensRepo = new Repositories\AccessTokenRepository(); $publicScopesRepo = new Repositories\PublicScopeRepository(); $internalScopesRepo = new Repositories\InternalScopeRepository(); $authCodesRepo = new Repositories\AuthCodeRepository(); $refreshTokensRepo = new Repositories\RefreshTokenRepository(); $accessTokenTTL = new DateInterval('P1D'); $authServer = new AuthorizationServer( $clientsRepo, $accessTokensRepo, new Repositories\EmptyScopeRepository(), new EmptyKey(), '', // omit key because we use our own encryption mechanism new ResponseTypes\BearerTokenResponse() ); /** @noinspection PhpUnhandledExceptionInspection */ $authCodeGrant = new Grants\AuthCodeGrant($authCodesRepo, $refreshTokensRepo, new DateInterval('PT10M')); $authCodeGrant->disableRequireCodeChallengeForPublicClients(); $authServer->enableGrantType($authCodeGrant, $accessTokenTTL); $authCodeGrant->setScopeRepository($publicScopesRepo); // Change repository after enabling $refreshTokenGrant = new Grants\RefreshTokenGrant($refreshTokensRepo); $authServer->enableGrantType($refreshTokenGrant); $refreshTokenGrant->setScopeRepository($publicScopesRepo); // Change repository after enabling // TODO: make these access tokens live longer $clientCredentialsGrant = new Grants\ClientCredentialsGrant(); $authServer->enableGrantType($clientCredentialsGrant, $accessTokenTTL); $clientCredentialsGrant->setScopeRepository($internalScopesRepo); // Change repository after enabling $this->_authServer = $authServer; } return $this->_authServer; } }