Skip to content

Commit 899d7ba

Browse files
committed
README updated about security
1 parent 90bbc55 commit 899d7ba

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.rst

+42
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ and unmarshal request data from validation result
7878
# get body
7979
validated_body = result.body
8080
81+
# get security data
82+
validated_security = result.security
83+
8184
Request object should be instance of OpenAPIRequest class (See `Integrations`_).
8285

8386
Response
@@ -110,6 +113,45 @@ and unmarshal response data from validation result
110113
111114
Response object should be instance of OpenAPIResponse class (See `Integrations`_).
112115

116+
Security
117+
********
118+
119+
openapi-core supports security for authentication and authorization process. Security data for security schemas are accessible from `security` attribute of `RequestValidationResult` object.
120+
121+
For given security specification:
122+
123+
.. code-block:: yaml
124+
125+
security:
126+
- BasicAuth: []
127+
- ApiKeyAuth: []
128+
components:
129+
securitySchemes:
130+
BasicAuth:
131+
type: http
132+
scheme: basic
133+
ApiKeyAuth:
134+
type: apiKey
135+
in: header
136+
name: X-API-Key
137+
138+
you can access your security data the following:
139+
140+
.. code-block:: python
141+
142+
result = validator.validate(request)
143+
144+
# get basic auth decoded credentials
145+
result.security['BasicAuth']
146+
147+
# get api key
148+
result.security['ApiKeyAuth']
149+
150+
Supported security types:
151+
152+
* http – for Basic and Bearer HTTP authentications schemes
153+
* apiKey – for API keys and cookie authentication
154+
113155

114156
Customizations
115157
##############

0 commit comments

Comments
 (0)