php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

security configuration in openapi spec

Open seth9009 opened this issue 6 years ago • 7 comments

I want to have the API docs open and visible for everyone, but some endpoints i want to be protected and should show a lock next to it like here https://petstore.swagger.io is this possible in current implementation?

seth9009 avatar Apr 09 '19 14:04 seth9009

It requires a 'security' specification in the openapi json. In the current implementation this is not possible as you need to somehow specify that exposing the existence is not a security breach. Such fine grained control is not implemented. It is either allowed (in which case it is shown) or not, in which case it is hidden. I hope you understand the reasoning.

You can use the 'openApiBase' config parameter to add default configuration to the openapi spec.

mevdschee avatar Apr 09 '19 16:04 mevdschee

The way I would envision this was, if auth is setup then all routes are with a lock and can't be tested without keys, rather than hidden them, but I understand that isn't working like that, thanks again for your reply really appreciate it!!

seth9009 avatar Apr 09 '19 18:04 seth9009

I understand your reasoning and it can be implemented.

But with the current implementation it would expose the existence all non-visible tables and columns as there is only a boolean defining whether or not a table or column should be exposed during a session.

mevdschee avatar Apr 09 '19 22:04 mevdschee

I'll convert this to a feature request for future reference.

mevdschee avatar Apr 12 '19 08:04 mevdschee

Piggying back on this... would it be possible to make the /openapi endpoint world-readable when authorization middleware is used?

Niek avatar Dec 10 '19 14:12 Niek

@Niek: allow the 'document' permission, see: https://github.com/mevdschee/php-crud-api/blob/3161ca4f1fd45d0f7fa7f4e2d7a2dfa0c3aa27cf/src/Tqdev/PhpCrudApi/RequestUtils.php#L48

mevdschee avatar Dec 10 '19 14:12 mevdschee

@mevdschee correct me if I'm wrong, but that is to hide certain tables from the documentation, right? As far as I see it can't be used to make the /openapi endpoint accessible without being logged in.

Niek avatar Dec 10 '19 14:12 Niek