[BUG] PHPSlim4 - Want only 1 authentication method out of multiple
See original GitHub issueBug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What’s the version of OpenAPI Generator used? 4.2.1
- Have you search for related issues/PRs?
- What’s the actual output vs expected output? Actual: adds all security schemes in middlewares that all get executed. Expected: only one security scheme should match.
Description
The generator does not take into account the fact that multiple security schemes are defined as ‘OR’. In other words, the generated PHP Slim code will always try to perform all authentication methods simultaneously.
They are added in the middewares like this:
$this->addRoute(..
$middlewares
)->setName($operation['operationId']);
openapi-generator version
4.2.1
OpenAPI declaration file content or url
get:
...
security:
-
AdminToken: []
-
UserJWT: []
-
ExternalToken: []
Steps to reproduce
Create an OpenApi operation with multiple possible security schemes.
Related issues/PRs
Looks similar to https://github.com/OpenAPITools/openapi-generator/issues/3844 for Python. Also https://github.com/OpenAPITools/openapi-generator/issues/797 seems relavant.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Slim 4 Authentication (Lesson 14 ~ Register, Login & Logout)
On top of that we're going to add a global Auth class of static methods allowing us determine if the current user is...
Read more >Slim 4 - Tutorial | Daniel Opitz - Blog
This tutorial shows you how to work with the powerful and lightweight Slim 4 framework.
Read more >Remove specific routes from middleware in SLIM
Use a Route middleware instead of Application middleware. A route middleware will be only called if the Route matches the current HTTP ...
Read more >Creating REST Service with PHP from a Java programmer's ...
First you install Apache Server, and then PHP extension on it. That, as I said was quite an effort. However, he did it...
Read more >User authentication using Angularjs, PHP, Mysql - Angularcode
The only file you need to change is the “config.php” [ This file contains the database login information. Put your database credentials here...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think the example provided by @richardwhiuk is correct to explain AND, OR in security definitions for endpoints.
Your example (even more complex) is also correct.
Should be confirmed, but my understanding of the spec is:
The first specifies a Security Requirement object with two requirements.
The second gives two options for the Security Requirement object, one of which must be satisfied.