zend framework2 - How to check for oAuth2 scopes in Apigility? -
i creating apigility project hosting of our apis. need able use oauth2 authentication cannot figure out how control access apis, seems once client authenticates, can use of our apis want limit them use specific ones define. after reading oauth2 library apigility uses, saw there scopes can defined have not found documentation how check user's scope see if have access. want find out if best way restrict access apis , how set if is, or there better way control access?
just implemented functionality using following recipe ...
https://github.com/remiq/apigility-zfc-rbac-recipe
it worked , took few hours working.
alternatively can checking in controller action (resource method)
$identity = $this->getidentity()->getauthenticationidentity(); $scope = $identity["scope"] if (! in_array('admin', $scope)) { return new apiproblem(response::status_code_401, 'no auth'); }
the above code untested should on right path if wanted way
Comments
Post a Comment