oauth2-bundle icon indicating copy to clipboard operation
oauth2-bundle copied to clipboard

Restricting routes by scope example

Open slawekadamek opened this issue 3 years ago • 1 comments

Hello I have a problem with Restricting routes by scope described in: https://github.com/trikoder/oauth2-bundle/blob/v3.x/docs/basic-setup.md#restricting-routes-by-scope there is an example which doesn't work for me:

oauth2_restricted: path: /api/restricted controller: 'App\Controller\FooController::barAction' defaults: oauth2_scopes: ['foo', 'bar']

Where - in which file should it be defined ? in 'security.yaml' or 'trikoder_oauth2.yaml' or some other - in which section ?

Thank you :)

slawekadamek avatar Jul 13 '21 14:07 slawekadamek

Yeah, trikoder could have done better with docs... You should set it in your controller. If you use annotations in symfony it would be something like this:

/**
 * @Route("/api/restricted", defaults={"oauth2_scopes"={"foo","bar"}})
 */
public function barAction(Request $request) 
{...

maciekstary avatar Apr 07 '22 12:04 maciekstary