From 9f3648039b92cab9061e9e6dd71a82f0ee6b4bcf Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sun, 17 Apr 2016 12:41:28 +0100 Subject: [PATCH] Use resource server instead --- examples/public/api.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/public/api.php b/examples/public/api.php index 3c446abb..c82ac5b3 100644 --- a/examples/public/api.php +++ b/examples/public/api.php @@ -1,9 +1,8 @@ function () { // Setup the authorization server - $server = new Server( - new ClientRepository(), + $server = new ResourceServer( new AccessTokenRepository(), - new ScopeRepository(), - 'file://' . __DIR__ . '/../private.key', 'file://' . __DIR__ . '/../public.key' ); @@ -54,12 +50,14 @@ $app->get('/users', function (ServerRequestInterface $request, ResponseInterface ], ]; + // If the access token doesn't have the `basic` scope hide users' names if (in_array('basic', $request->getAttribute('oauth_scopes')) === false) { for ($i = 0; $i < count($users); $i++) { unset($users[$i]['name']); } } + // If the access token doesn't have the `emal` scope hide users' email addresses if (in_array('email', $request->getAttribute('oauth_scopes')) === false) { for ($i = 0; $i < count($users); $i++) { unset($users[$i]['email']);