@@ -56,19 +56,23 @@ If you need other algorithms you should install it manually.
5656
5757For a basic usage you shouldn't require any other dependency package.
5858
59+ Every builder have methods to customize instances with other dependencies.
60+
5961``` php
6062
6163use Facile\OpenIDClient\Client\ClientBuilder;
6264use Facile\OpenIDClient\Issuer\IssuerBuilder;
6365use Facile\OpenIDClient\Client\Metadata\ClientMetadata;
64- use Facile\OpenIDClient\Service\AuthorizationService ;
65- use Facile\OpenIDClient\Service\UserinfoService ;
66+ use Facile\OpenIDClient\Service\Builder\AuthorizationServiceBuilder ;
67+ use Facile\OpenIDClient\Service\Builder\UserInfoServiceBuilder ;
6668use Psr\Http\Message\ServerRequestInterface;
6769
6870$issuer = (new IssuerBuilder())
6971 ->build('https://example.com/.well-known/openid-configuration');
7072$clientMetadata = ClientMetadata::fromArray([
71- 'client_id' => 'client-id',
73+ 'client_id' => 'client-id',
74+ 'client_secret' => 'my-client-secret',
75+ 'token_endpoint_auth_method' => 'client_secret_basic', // the auth method tor the token endpoint
7276 'redirect_uris' => [
7377 'https://my-rp.com/callback',
7478 ],
@@ -80,7 +84,7 @@ $client = (new ClientBuilder())
8084
8185// Authorization
8286
83- $authorizationService = new AuthorizationService ();
87+ $authorizationService = ( new AuthorizationServiceBuilder())->build ();
8488$redirectAuthorizationUri = $authorizationService->getAuthorizationUri(
8589 $client,
8690 ['login_hint' => 'user_username'] // custom params
@@ -107,20 +111,22 @@ $tokenSet = $authorizationService->refresh($client, $tokenSet->getRefreshToken()
107111
108112
109113// Get user info
110-
111- $userinfoService = new UserinfoService();
112- $userinfo = $userinfoService->getUserInfo($client, $tokenSet);
114+ $userInfoService = (new UserInfoServiceBuilder())->build();
115+ $userInfo = $userInfoService->getUserInfo($client, $tokenSet);
113116
114117```
115118
116119
117120## Client registration
118121
122+ See [ OpenID Connect Dynamic Client Registration 1.0] ( https://openid.net/specs/openid-connect-registration-1_0.html )
123+ and [ RFC7591 OAuth 2.0 Dynamic Client Registration Protocol] ( https://tools.ietf.org/html/rfc7591 ) .
124+
119125``` php
120126
121- use Facile\OpenIDClient\Service\RegistrationService ;
127+ use Facile\OpenIDClient\Service\Builder\RegistrationServiceBuilder ;
122128
123- $registration = new RegistrationService ();
129+ $registration = ( new RegistrationServiceBuilder())->build ();
124130
125131// registration
126132$metadata = $registration->register(
@@ -152,29 +158,33 @@ $registration->delete($metadata['registration_client_uri'], $metadata['registrat
152158
153159## Token Introspection
154160
161+ See [ RFC7662 - OAuth 2.0 Token Introspection] ( https://tools.ietf.org/html/rfc7662 ) .
162+
155163``` php
156- use Facile\OpenIDClient\Service\IntrospectionService ;
164+ use Facile\OpenIDClient\Service\Builder\IntrospectionServiceBuilder ;
157165
158- $service = new IntrospectionService ();
166+ $service = ( new IntrospectionServiceBuilder())->build ();
159167
160168$params = $service->introspect($client, $token);
161169```
162170
163171
164172## Token Revocation
165173
174+ See [ RFC7009 - OAuth 2.0 Token Revocation] ( https://tools.ietf.org/html/rfc7009 ) .
175+
166176``` php
167- use Facile\OpenIDClient\Service\RevocationService ;
177+ use Facile\OpenIDClient\Service\Builder\RevocationServiceBuilder ;
168178
169- $service = new RevocationService ();
179+ $service = ( new RevocationServiceBuilder())->build ();
170180
171181$params = $service->revoke($client, $token);
172182```
173183
174184
175185## Request Object
176186
177- You can create a request object authorization request with the
187+ You can create a [ request object] ( https://openid.net/specs/openid-connect-core-1_0.html#RequestUriParameter ) authorization request with the
178188` Facile\OpenIDClient\RequestObject\RequestObjectFactory ` class.
179189
180190This will create a signed (and optionally encrypted) JWT token based on
@@ -184,7 +194,7 @@ your client metadata.
184194use Facile\OpenIDClient\RequestObject\RequestObjectFactory;
185195
186196$factory = new RequestObjectFactory();
187- $requestObject = $factory->create($client, [/* custom params to include in the JWT*/]);
197+ $requestObject = $factory->create($client, [/* custom claims to include in the JWT*/]);
188198```
189199
190200Then you can use it to create the AuthRequest:
@@ -202,18 +212,18 @@ $authRequest = AuthRequest::fromParams([
202212
203213## Aggregated and Distributed Claims
204214
205- The library can handle aggregated and distributed claims:
215+ The library can handle [ aggregated and distributed claims] ( https://openid.net/specs/openid-connect-core-1_0.html#AggregatedDistributedClaims ) :
206216
207217``` php
208218use Facile\OpenIDClient\Claims\AggregateParser;
209219use Facile\OpenIDClient\Claims\DistributedParser;
210220
211221$aggregatedParser = new AggregateParser();
212222
213- $claims = $aggregatedParser->unpack($client, $userinfo );
223+ $claims = $aggregatedParser->unpack($client, $userInfo );
214224
215225$distributedParser = new DistributedParser();
216- $claims = $distributedParser->fetch($client, $userinfo );
226+ $claims = $distributedParser->fetch($client, $userInfo );
217227````
218228
219229
@@ -224,7 +234,7 @@ There are some middlewares and handles available:
224234### SessionCookieMiddleware
225235
226236This middleware should always be on top of middlewares chain to provide
227- a cookie session for `state` and `nonce` parameters.
237+ a session for `state` and `nonce` parameters.
228238
229239To use it you should install the `dflydev/fig-cookies` package:
230240
@@ -234,8 +244,11 @@ $ composer require "dflydev/fig-cookies:^2.0"
234244
235245```php
236246use Facile\OpenIDClient\Middleware\SessionCookieMiddleware;
247+ use Psr\SimpleCache\CacheInterface;
237248
238- $middleware = new SessionCookieMiddleware();
249+ // Use your PSR-16 simple-cache implementation to persist sessions
250+ /** @var CacheInterface $cache */
251+ $middleware = new SessionCookieMiddleware($cache/* , $cookieName = "openid", $ttl = 300 */);
239252```
240253
241254The middleware provides a ` Facile\OpenIDClient\Session\AuthSessionInterface `
@@ -314,24 +327,26 @@ with user infos as array.
314327
315328``` php
316329use Facile\OpenIDClient\Middleware\UserInfoMiddleware;
317- use Facile\OpenIDClient\Service\UserinfoService ;
330+ use Facile\OpenIDClient\Service\UserInfoService ;
318331
319- /** @var UserinfoService $userinfoService */
320- $userinfoService = $container->get(UserinfoService ::class);
321- $middleware = new UserInfoMiddleware($userinfoService );
332+ /** @var UserInfoService $userInfoService */
333+ $userInfoService = $container->get(UserInfoService ::class);
334+ $middleware = new UserInfoMiddleware($userInfoService );
322335```
323336
324337
325338## Performance improvements for production environment
326339
340+ It's important to use a cache to avoid to fetch issuer configuration and keys on every request.
341+
327342``` php
328343use Psr\SimpleCache\CacheInterface;
329344use Facile\OpenIDClient\Issuer\IssuerBuilder;
330345use Facile\OpenIDClient\Issuer\Metadata\Provider\MetadataProviderBuilder;
331346use Facile\JoseVerifier\JWK\JwksProviderBuilder;
332347
333348/** @var CacheInterface $cache */
334- $cache = $container->get('my -cache- implementation');
349+ $cache = $container->get(CacheInterface::class); // get your simple -cache implementation
335350
336351$metadataProviderBuilder = (new MetadataProviderBuilder())
337352 ->setCache($cache)
0 commit comments