users icon indicating copy to clipboard operation
users copied to clipboard

Allow one path for both authenticated and unauthenticated users

Open Webguyatwork opened this issue 5 years ago • 2 comments

I'd like to have one route in my API be able to take requests and return the appropriate results based on whether or not an authentication or authorization has occurred. It seems by default, the path is blocked for unauthorized users. Using bypassAuth doesn't work here. How can I allow unprotected access and let the controller figure it out?

        [
            'role' => '*',
            'prefix' => 'Api',
            'controller' => 'Objects',
            'action' => ['index'],
        ],

I want to be able to show some public content for unauthorized users, then show protected content for authorized users.

Webguyatwork avatar Feb 04 '21 17:02 Webguyatwork

So, I understand you need an api path like /api/objects/index to be accessed for BOTH authenticated and not authenticated users at the same time, and return results based on that.

In this case you would need to define bypassAuth in your rule to make this action public. What's your problem in this case?

steinkel avatar Apr 26 '21 09:04 steinkel

Please specify the version of the plugin you're using. Thanks.

steinkel avatar Apr 26 '21 09:04 steinkel