Skip to content

Access control for custom endpoints #4963

@bfoese

Description

@bfoese

Documentation Issue

We have the following setup: We have one auth enabled collection "User". All other collections are not auth enabled, but we restrict access to the auto-generated CRUD endpoints via the access: { read: .., create: ...} configuration where we provide functions which check if the user is authenticated for the "User" collection.

Is it possible to somehow limit the access for custom endpoints in collections which are not auth enabled?
The documentation lacks information about this: https://payloadcms.com/docs/rest-api/overview#custom-endpoints.
The request object that was provided to the custom endpoint handler contained no authenticated user object. I assume the user was missing, because Passport would not kick in here to set the user on the request, when the endpoint is configured to not require authentication.

Additional Details

In case it is currently not possible to restrict access to custom endpoints the same way we can do this for the standard CRUD endpoints, this would be feature request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: docsImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions