You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/06/27 06:40:28 UTC
[GitHub] [airflow] aserechenko opened a new issue, #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
aserechenko opened a new issue, #24674:
URL: https://github.com/apache/airflow/issues/24674
### Apache Airflow version
2.3.0
### What happened
We are using a custom plugin with API endpoints that must be protected.
After upgrading from 2.1.5 to 2.3.0 our endpoints started to produce an error:
```
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/airflow/.local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/airflow/.local/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/airflow/.local/lib/python3.7/site-packages/flask_appbuilder/security/decorators.py", line 93, in wraps
if current_app.appbuilder.sm.is_item_public(
AttributeError: 'AirflowSecurityManager' object has no attribute 'is_item_public'
```
But the same error is produced on 2.3.2 as well.
### What you think should happen instead
_No response_
### How to reproduce
Full reproducing steps require making a plugin with a class:
```
from airflow.plugins_manager import AirflowPlugin
from testairflowplugin.views.test_api import test_api_view
class TestAirflowPlugin(AirflowPlugin):
name = 'test'
appbuilder_views = [
{
"view": test_api_view,
"name": "",
"category": "",
},
]
```
Example API class in `plugins/testplugin/views/test_api.py`:
```
from flask_appbuilder.api import BaseApi, expose
from flask_appbuilder.security.decorators import protect
from flask_appbuilder import permission_name
class TestAPIView(BaseApi):
route_base = "/api/v1/test"
@expose('/test', methods=['GET'])
@permission_name('test')
@protect()
def test(self):
return self.response(201, success=True, works="good")
```
### Operating System
Tried it on multiple OS: MacOS, inside docker on Linux, ...
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else
_No response_
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk closed issue #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
Posted by GitBox <gi...@apache.org>.
potiuk closed issue #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
URL: https://github.com/apache/airflow/issues/24674
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] aserechenko commented on issue #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
Posted by GitBox <gi...@apache.org>.
aserechenko commented on issue #24674:
URL: https://github.com/apache/airflow/issues/24674#issuecomment-1187389841
Found out it is possible to use inner Airflow security management:
```python
from airflow.api_connexion import security
from airflow.security import permissions
class YourAPIView(BaseApi):
@security.requires_access([(permissions.ACTION_CAN_READ, permissions.RESOURCE_DAG_CODE)])
@expose('/your_endpoint', methods=['GET'])
def your_endpoint(self):
```
Hope someone will find it useful, as it was in my case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] potiuk commented on issue #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #24674:
URL: https://github.com/apache/airflow/issues/24674#issuecomment-1174390402
Correct. SecurityManager is a trimmed-down version of FAB Security Manager that only implements subset needed to implement the UI and it does not implement all features. But You are free to copy&paste relevant code from FAB security Manager if you need to use the code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] boring-cyborg[bot] commented on issue #24674: AirflowSecurityManager inconsistent with Flask-appbuilder when using @protect API in custom plugins
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #24674:
URL: https://github.com/apache/airflow/issues/24674#issuecomment-1166940373
Thanks for opening your first issue here! Be sure to follow the issue template!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org