mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-03 10:41:51 +05:30
Use resource server instead
This commit is contained in:
parent
08c356a1e1
commit
9f3648039b
@ -1,9 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use League\OAuth2\Server\ResourceServer;
|
||||||
use League\OAuth2\Server\Server;
|
use League\OAuth2\Server\Server;
|
||||||
use OAuth2ServerExamples\Repositories\AccessTokenRepository;
|
use OAuth2ServerExamples\Repositories\AccessTokenRepository;
|
||||||
use OAuth2ServerExamples\Repositories\ClientRepository;
|
|
||||||
use OAuth2ServerExamples\Repositories\ScopeRepository;
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Slim\App;
|
use Slim\App;
|
||||||
@ -16,11 +15,8 @@ $app = new App([
|
|||||||
],
|
],
|
||||||
Server::class => function () {
|
Server::class => function () {
|
||||||
// Setup the authorization server
|
// Setup the authorization server
|
||||||
$server = new Server(
|
$server = new ResourceServer(
|
||||||
new ClientRepository(),
|
|
||||||
new AccessTokenRepository(),
|
new AccessTokenRepository(),
|
||||||
new ScopeRepository(),
|
|
||||||
'file://' . __DIR__ . '/../private.key',
|
|
||||||
'file://' . __DIR__ . '/../public.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) {
|
if (in_array('basic', $request->getAttribute('oauth_scopes')) === false) {
|
||||||
for ($i = 0; $i < count($users); $i++) {
|
for ($i = 0; $i < count($users); $i++) {
|
||||||
unset($users[$i]['name']);
|
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) {
|
if (in_array('email', $request->getAttribute('oauth_scopes')) === false) {
|
||||||
for ($i = 0; $i < count($users); $i++) {
|
for ($i = 0; $i < count($users); $i++) {
|
||||||
unset($users[$i]['email']);
|
unset($users[$i]['email']);
|
||||||
|
Loading…
Reference in New Issue
Block a user