Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow one path for both authenticated and unauthenticated users #941

Open
Webguyatwork opened this issue Feb 4, 2021 · 2 comments
Open
Assignees

Comments

@Webguyatwork
Copy link

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.

@steinkel
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants