exafs 1.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- exafs-1.1.6.dist-info/METADATA +151 -0
- exafs-1.1.6.dist-info/RECORD +116 -0
- exafs-1.1.6.dist-info/WHEEL +5 -0
- exafs-1.1.6.dist-info/licenses/LICENSE +21 -0
- exafs-1.1.6.dist-info/top_level.txt +1 -0
- flowapp/__about__.py +5 -0
- flowapp/__init__.py +148 -0
- flowapp/auth.py +215 -0
- flowapp/constants.py +71 -0
- flowapp/flowspec.py +100 -0
- flowapp/forms/__init__.py +40 -0
- flowapp/forms/api.py +68 -0
- flowapp/forms/base.py +50 -0
- flowapp/forms/choices.py +81 -0
- flowapp/forms/organization.py +47 -0
- flowapp/forms/rules/__init__.py +17 -0
- flowapp/forms/rules/base.py +127 -0
- flowapp/forms/rules/ipv4.py +70 -0
- flowapp/forms/rules/ipv6.py +64 -0
- flowapp/forms/rules/rtbh.py +104 -0
- flowapp/forms/rules/whitelist.py +66 -0
- flowapp/forms/user.py +91 -0
- flowapp/instance_config.py +144 -0
- flowapp/messages.py +224 -0
- flowapp/models/__init__.py +71 -0
- flowapp/models/api.py +40 -0
- flowapp/models/base.py +16 -0
- flowapp/models/community.py +79 -0
- flowapp/models/log.py +39 -0
- flowapp/models/organization.py +35 -0
- flowapp/models/rules/__init__.py +6 -0
- flowapp/models/rules/base.py +69 -0
- flowapp/models/rules/flowspec.py +294 -0
- flowapp/models/rules/rtbh.py +153 -0
- flowapp/models/rules/whitelist.py +172 -0
- flowapp/models/user.py +79 -0
- flowapp/models/utils.py +376 -0
- flowapp/output.py +140 -0
- flowapp/services/__init__.py +21 -0
- flowapp/services/base.py +93 -0
- flowapp/services/rule_service.py +610 -0
- flowapp/services/whitelist_common.py +244 -0
- flowapp/services/whitelist_service.py +198 -0
- flowapp/static/js/enable_tooltips.js +4 -0
- flowapp/static/js/ip_context.js +231 -0
- flowapp/static/mystyle.css +191 -0
- flowapp/static/swagger.yml +481 -0
- flowapp/templates/errors/401.html +7 -0
- flowapp/templates/errors/401.j2 +7 -0
- flowapp/templates/errors/404.html +6 -0
- flowapp/templates/errors/500.html +6 -0
- flowapp/templates/forms/api_key.html +39 -0
- flowapp/templates/forms/bulk_user_form.html +59 -0
- flowapp/templates/forms/ipv4_rule.html +95 -0
- flowapp/templates/forms/ipv6_rule.html +88 -0
- flowapp/templates/forms/machine_api_key.html +48 -0
- flowapp/templates/forms/macros.html +120 -0
- flowapp/templates/forms/org.html +35 -0
- flowapp/templates/forms/rtbh_rule.html +75 -0
- flowapp/templates/forms/rule.html +105 -0
- flowapp/templates/forms/simple_form.html +11 -0
- flowapp/templates/forms/whitelist.html +62 -0
- flowapp/templates/layouts/default.html +117 -0
- flowapp/templates/macros.html +219 -0
- flowapp/templates/pages/actions.html +35 -0
- flowapp/templates/pages/api_key.html +51 -0
- flowapp/templates/pages/as_paths.html +27 -0
- flowapp/templates/pages/communities.html +41 -0
- flowapp/templates/pages/dashboard_admin.html +25 -0
- flowapp/templates/pages/dashboard_search.html +20 -0
- flowapp/templates/pages/dashboard_user.html +41 -0
- flowapp/templates/pages/dashboard_view.html +22 -0
- flowapp/templates/pages/dashboard_whois.html +11 -0
- flowapp/templates/pages/limit_reached.html +25 -0
- flowapp/templates/pages/logout.html +6 -0
- flowapp/templates/pages/logs.html +35 -0
- flowapp/templates/pages/machine_api_key.html +55 -0
- flowapp/templates/pages/org_modal.html +23 -0
- flowapp/templates/pages/orgs.html +53 -0
- flowapp/templates/pages/submenu_dashboard.html +67 -0
- flowapp/templates/pages/submenu_dashboard_view.html +58 -0
- flowapp/templates/pages/user_list.html +19 -0
- flowapp/templates/pages/users.html +43 -0
- flowapp/tests/__init__.py +0 -0
- flowapp/tests/conftest.py +232 -0
- flowapp/tests/rule_service_integration.py +332 -0
- flowapp/tests/test_api_auth.py +71 -0
- flowapp/tests/test_api_deprecated.py +28 -0
- flowapp/tests/test_api_v3.py +611 -0
- flowapp/tests/test_api_whitelist_integration.py +273 -0
- flowapp/tests/test_flowapp.py +14 -0
- flowapp/tests/test_flowspec.py +167 -0
- flowapp/tests/test_forms.py +65 -0
- flowapp/tests/test_forms_cl.py +608 -0
- flowapp/tests/test_login.py +0 -0
- flowapp/tests/test_models.py +498 -0
- flowapp/tests/test_rule_service.py +628 -0
- flowapp/tests/test_rule_service_reactivate_delete.py +527 -0
- flowapp/tests/test_utils.py +71 -0
- flowapp/tests/test_validators.py +547 -0
- flowapp/tests/test_whitelist_common.py +250 -0
- flowapp/tests/test_whitelist_service.py +461 -0
- flowapp/utils/__init__.py +46 -0
- flowapp/utils/app_factory.py +225 -0
- flowapp/utils/base.py +183 -0
- flowapp/validators.py +427 -0
- flowapp/views/__init__.py +0 -0
- flowapp/views/admin.py +693 -0
- flowapp/views/api_common.py +502 -0
- flowapp/views/api_keys.py +103 -0
- flowapp/views/api_v1.py +12 -0
- flowapp/views/api_v2.py +12 -0
- flowapp/views/api_v3.py +163 -0
- flowapp/views/dashboard.py +566 -0
- flowapp/views/rules.py +738 -0
- flowapp/views/whitelist.py +129 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: exafs
|
|
3
|
+
Version: 1.1.6
|
|
4
|
+
Summary: Tool for creation, validation, and execution of ExaBGP messages for network security.
|
|
5
|
+
Author: Petr Adamec, Josef Verich, Jakub Man
|
|
6
|
+
Author-email: Jiri Vrany <jiri.vrany@cesnet.cz>
|
|
7
|
+
Maintainer: Jiri Vrany
|
|
8
|
+
Project-URL: Homepage, https://github.com/CESNET/exafs
|
|
9
|
+
Project-URL: Repository, https://github.com/CESNET/exafs
|
|
10
|
+
Project-URL: Documentation, https://github.com/CESNET/exafs/blob/master/README.md
|
|
11
|
+
Project-URL: Issues, https://github.com/CESNET/exafs/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/CESNET/exafs/blob/master/README.md#change-log
|
|
13
|
+
Keywords: bgp,exabgp,flowspec,ddos,network-security,CESNET
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: Intended Audience :: Telecommunications Industry
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: System :: Networking
|
|
25
|
+
Classifier: Topic :: Security
|
|
26
|
+
Classifier: Framework :: Flask
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: Flask>=2.0.2
|
|
31
|
+
Requires-Dist: Flask-SQLAlchemy>=2.2
|
|
32
|
+
Requires-Dist: Flask-SSO>=0.4.0
|
|
33
|
+
Requires-Dist: Flask-WTF>=1.0.0
|
|
34
|
+
Requires-Dist: Flask-Migrate>=3.0.0
|
|
35
|
+
Requires-Dist: Flask-Script>=2.0.0
|
|
36
|
+
Requires-Dist: Flask-Session
|
|
37
|
+
Requires-Dist: PyJWT>=2.4.0
|
|
38
|
+
Requires-Dist: PyMySQL>=1.0.0
|
|
39
|
+
Requires-Dist: requests>=2.20.0
|
|
40
|
+
Requires-Dist: babel>=2.7.0
|
|
41
|
+
Requires-Dist: email_validator>=1.1
|
|
42
|
+
Requires-Dist: pika>=1.3.0
|
|
43
|
+
Requires-Dist: loguru
|
|
44
|
+
Requires-Dist: flasgger
|
|
45
|
+
Requires-Dist: python-dotenv
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# ExaFS
|
|
51
|
+
ExaFS brings new functionality to the environment of routing protocols configuration for backbone network hardware security.
|
|
52
|
+
|
|
53
|
+
The tool extends network administrators toolset by adding an extra layer for configuration rules creation, validation, and authorization. With this new layer, a larger group of network administrators can safely create new
|
|
54
|
+
[BGP protocol](https://github.com/Exa-Networks/exabgp) rules to prevent DDoS and other forms of malicious cyber attacks.
|
|
55
|
+
|
|
56
|
+
ExaFS is open source with MIT license. The system is regularly used at [CESNET](https://www.cesnet.cz/) - the Czech national e-infrastructure for science, research and education operator.
|
|
57
|
+
|
|
58
|
+
ExaFS provides both the user Web interface and the REST API for web service.
|
|
59
|
+
|
|
60
|
+
Key contributions of the system are **user authorization** mechanism and **validation system for BGP commands**.
|
|
61
|
+
|
|
62
|
+
Without ExaFS the system Root privileges are required for direct interaction with ExaBGP and networking hardware. ExaFS provides several user roles and access rights similarly to user roles in other software systems such as SQL. The system allows specifying user rights for various kinds of sub-nets following the network topology.
|
|
63
|
+
|
|
64
|
+
Validation system for BGP commands assures that only error-free messages can pass to the system BGP API. Both syntax and access rights are validated before a new rule can be stored in the database.
|
|
65
|
+
|
|
66
|
+
Thanks to the storage, all the rules can be restored quickly after a system reboot or failure. All rules are validated again, before sending them to ExaBPG from the storage, to prevent any malicious database manipulation.
|
|
67
|
+
|
|
68
|
+
ExaFS is an integral part of cybersecurity tools at CESNET. However, it can be used in any network where ExaBGP is available.
|
|
69
|
+
|
|
70
|
+
See how is ExaFS integrated into the network in the picture below.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
## Project presentations
|
|
76
|
+
|
|
77
|
+
* 2020 - CZ [DDoS Protector v prostředí propojovacího uzlu NIX.CZ](https://www.cesnet.cz/wp-content/uploads/2020/02/DDP_v_NIX.pdf), [Seminář o bezpečností sítí a služeb 2020](https://www.cesnet.cz/akce/bss20/)
|
|
78
|
+
* 2019 - EN [ExaFS: mitigating unwanted traffic](https://xn--ondej-kcb.caletka.cz/dl/slidy/20191113-SIGNOC-ExaFS.pdf), [10th SIG-NOC meeting](https://wiki.geant.org/display/SIGNOC/10th+SIG-NOC+meeting), Prague
|
|
79
|
+
* 2019 - CZ [Potlačení nežádoucího provozu pomocí BGP Flowspec](https://indico.csnog.eu/event/6/contributions/64/attachments/35/61/CESNET-FlowSpec-CSNOG.pdf), [CSNOG 2019](https://indico.csnog.eu/event/6/overview)
|
|
80
|
+
* 2019 - CZ [Nástroje pro FlowSpec a RTBH](https://konference.cesnet.cz/prezentace2019/sal1/3_Adamec.pdf), [Konference e-infrastruktury CESNET](https://konference.cesnet.cz/) 2019
|
|
81
|
+
* 2019 - CZ [Nástroje pro obranu proti útokům na páteřních směrovačích](https://konference.cesnet.cz/prezentace2019/sal1/3_Verich.pdf),[Konference e-infrastruktury CESNET](https://konference.cesnet.cz/) 2019
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## System overview
|
|
85
|
+
|
|
86
|
+

|
|
87
|
+
The core component of ExaFS is a web application written in Python using the Flask framework. It provides a user interface for managing ExaBGP rules (CRUD operations) and also exposes a REST API with similar functionality. The web application uses Shibboleth for authentication, while the REST API relies on token-based authentication.
|
|
88
|
+
|
|
89
|
+
The application generates ExaBGP commands and forwards them to the ExaBGP process. All rules are thoroughly validated—only valid rules are stored in the database and sent to the ExaBGP connector.
|
|
90
|
+
|
|
91
|
+
The second component of the system is a separate application that replicates received commands to `stdout`. The connection between the ExaBGP daemon and the `stdout` of the ExaAPI (ExaBGP process) is defined in the ExaBGP configuration.
|
|
92
|
+
|
|
93
|
+
This API was originally part of the same project but has since been moved to its own repository. You can use the [exabgp-process pip package](https://pypi.org/project/exabgp-process/), clone the Git repository, or develop your own implementation.
|
|
94
|
+
|
|
95
|
+
Each time this process receives a command from ExaFS, it outputs it to `stdout`, allowing the ExaBGP service to process the command and update its routing table—creating, modifying, or removing rules accordingly.
|
|
96
|
+
|
|
97
|
+
It may also be necessary to monitor ExaBGP and re-announce rules after a restart or shutdown. This can be handled via the ExaBGP service configuration, or by using an example system service called **Guarda**, described in the documentation. In either case, the key mechanism is calling the application endpoint `/rules/announce_all`. This endpoint is only accessible from `localhost`; a local IP address must be configured in the application settings.
|
|
98
|
+
|
|
99
|
+
## DOCS
|
|
100
|
+
### Instalation related
|
|
101
|
+
* [ExaFS Ansible deploy](https://github.com/CESNET/ExaFS-deploy) - repository with Ansbile playbook for deploying ExaFS with Docker Compose.
|
|
102
|
+
* [Install notes](./docs/INSTALL.md)
|
|
103
|
+
* [Database backup configuration](./docs/DB_BACKUP.md)
|
|
104
|
+
* [Local database instalation notes](./docs/DB_LOCAL.md)
|
|
105
|
+
### API
|
|
106
|
+
The REST API is documented using Swagger (OpenAPI). After installing and running the application, the API documentation is available locally at the /apidocs/ endpoint. This interactive documentation provides details about all available endpoints, request and response formats, and supported operations, making it easier to integrate and test the API.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Change Log
|
|
111
|
+
- 1.1.6 - Fixed problem with session overflow on too much rules id. Updated withdraw_expired method to delete also expired rules. Expiration treshold can be set in config - default to 30 days.
|
|
112
|
+
- 1.1.5 - introduced instance config override. Copy the sample to instance_config_override.py and customize you dashboard menu items easily. For normal installations no override is needed.
|
|
113
|
+
- 1.1.4 - minor bug fixes and code cleanup
|
|
114
|
+
- 1.1.3 - introduced configurable footer menu for links in bottom of the default template
|
|
115
|
+
- 1.1.2 - minor security updates (removed unused JS files), setup.py now reads dependencies from requirements.txt
|
|
116
|
+
- 1.1.1 - Machine API Key rewrited.
|
|
117
|
+
- API keys for machines are now tied to one of the existing users. If there is a need to have API access for machine, first create service user, and set the access rights. Then create machine key as Admin and assign it to this user.
|
|
118
|
+
- 1.1.0 - Major Architecture Refactoring and Whitelist Integration
|
|
119
|
+
- Code Organization and Architecture Improvements. Significant architectural refactoring focused on better separation of concerns and improved maintainability. The most notable change is the introduction of a dedicated **services layer** that extracts business logic from view controllers. Key service modules include `rule_service.py` for rule management operations, `whitelist_service.py` for whitelist functionality, and `whitelist_common.py` for shared whitelist utilities.
|
|
120
|
+
- The **models structure** has been reorganized with better separation into logical modules. Rule models are now organized under `flowapp/models/rules/` with separate files for different rule types (`flowspec.py`, `rtbh.py`, `whitelist.py`), while maintaining backward compatibility through the main models `__init__.py`. Form handling has also been improved with better organization under `flowapp/forms/` and enhanced validation logic.
|
|
121
|
+
- **RTBH Whitelist Integration** This system automatically evaluates new RTBH rules against existing whitelists and can automatically modify or block rules that conflict with whitelisted networks. When an RTBH rule is created that intersects with a whitelist entry, the system can:
|
|
122
|
+
- **Automatically whitelist** rules that exactly match or are contained within whitelisted networks
|
|
123
|
+
- **Create subnet rules** when RTBH rules are supersets of whitelisted networks, automatically generating the non-whitelisted portions
|
|
124
|
+
- **Maintain rule cache** that tracks relationships between rules and whitelists for proper cleanup
|
|
125
|
+
- 1.0.2 - fixed bug in IPv6 Flowspec messages
|
|
126
|
+
- 1.0.1 . minor bug fixes
|
|
127
|
+
- 1.0.0 . Major changes
|
|
128
|
+
- Limits for nuber of rules in the system introduced. There are now limits for rules for organization and overall limit for the instalation. Database changed / migration is required. Migrating the database to version 1.0.x is a bit more complicated, you need to link existing rules to organizations. [A more detailed description is in a separate document](./docs/DB_MIGRATIONS.md).
|
|
129
|
+
- Rules are now tied to organization. If the user belongs to more than one organization, the organization for the session must be selected after login.
|
|
130
|
+
- Bulk import for users enabled for admin.
|
|
131
|
+
- Introduced Swagger docs for API on the local system. Just open /apidocs url.
|
|
132
|
+
- New format of message for ExaAPI - now sends information about author of rule (user) for logging purposes.
|
|
133
|
+
- ExaAPI and Guarda modules moved outside of the project.
|
|
134
|
+
- ExaAPI is now available as a [pip package exabgp-process](https://pypi.org/project/exabgp-process/), with own [github repostiory](https://github.com/CESNET/exabgp-process).
|
|
135
|
+
- Watch of exabgp restart can be still done by guarda service - see docs. Or it can be done by override of the exabgp service settings.
|
|
136
|
+
- 0.8.1 application is using Flask-Session stored in DB using SQL Alchemy driver. This can be configured for other drivers, however server side session is required for the application proper function.
|
|
137
|
+
- 0.8.0 - API keys update. **Run migration scripts to update your DB**. Keys can now have expiration date and readonly flag. Admin can create special keys for certain machinnes.
|
|
138
|
+
- 0.7.3 - New possibility of external auth proxy.
|
|
139
|
+
- 0.7.2 - Dashboard and Main menu are now customizable in config. App is ready to be packaged using setup.py.
|
|
140
|
+
- 0.7.0 - ExaAPI now have two options - HTTP or RabbitMQ. ExaAPI process has been renamed, update of ExaBGP process value is needed for this version.
|
|
141
|
+
- 0.6.2 - External config for ExaAPI
|
|
142
|
+
- 0.6.0 - Bootstrap 5 in UI
|
|
143
|
+
- 0.5.5 - API v3 - auth api key in cookie not in url
|
|
144
|
+
- 0.5.4 - Right click menu on adress / Whois or Copy to clipboard
|
|
145
|
+
- 0.5.3 - Dashboard update, forms with default action
|
|
146
|
+
- 0.5.2 - API v2 with new keys
|
|
147
|
+
- 0.5.1 - Bug fixes
|
|
148
|
+
- 0.5.0 - New format of LOG table in database. **Run migration scripts to update your DB**. Removed foreign key user_id, author email is stored directly to logs for faster grep text search.
|
|
149
|
+
- 0.4.8 - Enhanced String Filtering
|
|
150
|
+
- 0.4.7 - Multi neighbor support enabled. See config example and update your config.py.
|
|
151
|
+
- 0.4.6 - Route Distinguisher for VRF is now supported. See config example and update your config.py.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
exafs-1.1.6.dist-info/licenses/LICENSE,sha256=sFVa2GIFSw1lDZODIXcN6siuqCPq6TcqdmX32JkBnew,1101
|
|
2
|
+
flowapp/__about__.py,sha256=EHszKHoanCG55XOdSmLiN46sWAWxSa5jWWybpetrHb8,225
|
|
3
|
+
flowapp/__init__.py,sha256=MH7pV_0p68r8jKrZqAOkhvZjwrdsTzUxvnTTnp_mvmM,3972
|
|
4
|
+
flowapp/auth.py,sha256=2MMoaB3mxp8h-JsBfQi9SBSQMV1sfVuxpU6ySRJj-mQ,6358
|
|
5
|
+
flowapp/constants.py,sha256=3Hr-4J8oKR2QLXNukfCfGf6_GPZd8G0amQzIblo_5KA,1406
|
|
6
|
+
flowapp/flowspec.py,sha256=UccBFfmokcS5wm_zvQ5CoCgFgiVgBmgQhHnlwXEh39I,3484
|
|
7
|
+
flowapp/instance_config.py,sha256=-qQ8qwQpURk-tANdxYm45oHSToUGF9wwiXCjGvzFXbU,5031
|
|
8
|
+
flowapp/messages.py,sha256=Chuou73NsdVV5TtyXjCwN6m_rBLOmQ7zBE_WfqwIbKE,7452
|
|
9
|
+
flowapp/output.py,sha256=tsWxkFz0A-ouGJsm43eX27Q4piU1tE5hOkT49oTY1hk,4169
|
|
10
|
+
flowapp/validators.py,sha256=lJOZ3L271flkHVUwMe8sTOp650ozk2-gYsFp57NdTsw,13096
|
|
11
|
+
flowapp/forms/__init__.py,sha256=w1kLSyv5ASLBO5bNsMlOEghc7cN5Bltm7uGZcaPUk44,842
|
|
12
|
+
flowapp/forms/api.py,sha256=0KKoMxpfdyehdza3G_14tjMCNmgQ16x2zbHb8SU4W0I,1977
|
|
13
|
+
flowapp/forms/base.py,sha256=rUzLCrbbJIePE6SGWdFKUWx5aEPBbkDkMD6IdHt0VoA,1566
|
|
14
|
+
flowapp/forms/choices.py,sha256=iluNMaFuKdybwsMFfFQvElTXVosGefDOwJJoCLiaWhw,2212
|
|
15
|
+
flowapp/forms/organization.py,sha256=AeMQUG7m4VQfLN2FL0IiYb_h9CbhXHXkJhB424f8-iw,1287
|
|
16
|
+
flowapp/forms/user.py,sha256=9gfJSSoTPNvEbpWqJU4DTJm9P9f_bpwuLU-Ua84UcoE,3077
|
|
17
|
+
flowapp/forms/rules/__init__.py,sha256=8xLw2rTbMfG9IxwIxMA1a7LnBfFc04xZQ0Lxf1WXy90,290
|
|
18
|
+
flowapp/forms/rules/base.py,sha256=EamS05M6TexwlHfuiZpBTgXdZZ0EMk-LHiRZbJeA1JY,4455
|
|
19
|
+
flowapp/forms/rules/ipv4.py,sha256=hcCJ7R8VODsXZ1oAKUQqX4eR7S1TxSzd-UJ8VC4coq8,2017
|
|
20
|
+
flowapp/forms/rules/ipv6.py,sha256=rCU_QoMuMbdY6H0HCGK-4wdwBeGOkdSp4xvscSFebK4,1811
|
|
21
|
+
flowapp/forms/rules/rtbh.py,sha256=of_4_Om-MmgUJxMCxiQz7LsxKEYitHc_78TvsF_RIUg,3400
|
|
22
|
+
flowapp/forms/rules/whitelist.py,sha256=BXsbATPF7gj0dIZK8kj5aOmYyx0_trLqA5dBXrtvOnY,1986
|
|
23
|
+
flowapp/models/__init__.py,sha256=o00YQT9ZaqdfTnGWXpPp4n45mmE3tzKE6SA5Aemv6Jc,1680
|
|
24
|
+
flowapp/models/api.py,sha256=RTb9s4U0-2vvazp7O1PU1fR0MG__orvK2sdUpIktn0w,1565
|
|
25
|
+
flowapp/models/base.py,sha256=cBrheg5k19X84T44Le1oc7Y2F0cx4TaTcCDTFynbNrU,592
|
|
26
|
+
flowapp/models/community.py,sha256=aouigBWkJU5oPlxKDn01VCCCtxD-E1X58jISeCZ4r24,2156
|
|
27
|
+
flowapp/models/log.py,sha256=z_rL4x-Iyg6LpnkZrpplvqosrUAHSSARoiFyMyWdAjg,1223
|
|
28
|
+
flowapp/models/organization.py,sha256=okhtgSkHx9hTtxLYgjqgyEGVF_1mguGA7KYR8S8TG_w,1274
|
|
29
|
+
flowapp/models/user.py,sha256=SO9YT_O7CsigFTXBUqxsUnWX0q-r4STSB31rn9ahSNY,2714
|
|
30
|
+
flowapp/models/utils.py,sha256=GkMYGozElCBKR_7zIvvO1t6LiBOG6VDF009D693Ply0,11878
|
|
31
|
+
flowapp/models/rules/__init__.py,sha256=-Cm9vK_Lu1ymy24FS6uAGW0KLhL5QB_U-51QkvkE5bo,253
|
|
32
|
+
flowapp/models/rules/base.py,sha256=F6sw6Ie2-08gCvuTAbxnuwguguG6XeG3Ad57oB11hlk,2077
|
|
33
|
+
flowapp/models/rules/flowspec.py,sha256=1_PeoL_KXGzSjBVJpjLlYLWklgiXyFrENfodQ9GXd0s,10193
|
|
34
|
+
flowapp/models/rules/rtbh.py,sha256=La_qNSQCdVjsfrN8TMHybNBSttcXcZah2nKNQe36ZVs,5068
|
|
35
|
+
flowapp/models/rules/whitelist.py,sha256=v-rFmGDOPiF8GzJWoY3f97Ipycv3SJVTfnvx8YglqBs,5475
|
|
36
|
+
flowapp/services/__init__.py,sha256=93vaq1fWEUyhANyAL2H9uvZo3dMXiHeCoQ0HKelVH6o,532
|
|
37
|
+
flowapp/services/base.py,sha256=3jX_P3zA0EsxjEvOmPdNC61HeK_U5_qhYQo-fyqwpq8,2865
|
|
38
|
+
flowapp/services/rule_service.py,sha256=zuAZCaAs9gI6vywFTyybr5oMNzoBbLQ65UTiCr5uGwo,20213
|
|
39
|
+
flowapp/services/whitelist_common.py,sha256=P53Djp83nJUQqVJj0_Zm25qWKWmzlRRkr_Ls39zYdVI,8544
|
|
40
|
+
flowapp/services/whitelist_service.py,sha256=pLqP_bDtCgv4X74seybEjUmeFGWGZHG07iv8t96rdv0,8369
|
|
41
|
+
flowapp/static/mystyle.css,sha256=lEZWuBnu_cXu4NdhFX9HVQqq44sLcoeEhtlBf4f2zqY,2751
|
|
42
|
+
flowapp/static/swagger.yml,sha256=l8KbSLoacalbYmDfoeyEPlRu6H6oJb_Hxdz1cE-0iNk,11831
|
|
43
|
+
flowapp/static/js/enable_tooltips.js,sha256=G7JYGhUdqlQrb4jsPSo8Etbjfldh2PIkaIkq4bdlCBU,218
|
|
44
|
+
flowapp/static/js/ip_context.js,sha256=RAbM-gnGaG_0yq0VQehxmrDvsW_fTCQwzE7vwWh-R_w,5018
|
|
45
|
+
flowapp/templates/macros.html,sha256=0I0z_XYDAO57uxoNzwZiVX2VLbJHAFg8sDOGyVczrg8,8603
|
|
46
|
+
flowapp/templates/errors/401.html,sha256=1g73WkUR0RJfCa3BipT0kGiaNyBG6On18Dmonc4XMls,258
|
|
47
|
+
flowapp/templates/errors/401.j2,sha256=08uBOpANsbGEW7rqF3I3pL2qU2dOWBj1cFxrs9bQZqs,256
|
|
48
|
+
flowapp/templates/errors/404.html,sha256=K9EuhxJ6RXrinS5KCnIV1HqD-4hjGLRzuKRx_B-vSKY,172
|
|
49
|
+
flowapp/templates/errors/500.html,sha256=f5raFEMfB_lhmxxvA614Ld4dZ7B87txBtRPM-OqjWMc,160
|
|
50
|
+
flowapp/templates/forms/api_key.html,sha256=mBaYQst-K-XKf_8Pbczy43F5DmPQAH25PnDTZj6T4iM,981
|
|
51
|
+
flowapp/templates/forms/bulk_user_form.html,sha256=PtH9YmLQd-Nrxf2ovKJYTSkcMDjczpk0OPYn0RYEKoo,1864
|
|
52
|
+
flowapp/templates/forms/ipv4_rule.html,sha256=hoBmdwLLbGe2To1IEZf4BeBDApx2gblSmIu0V60SSXw,2713
|
|
53
|
+
flowapp/templates/forms/ipv6_rule.html,sha256=svakSkdifjHfDBhhDoMEgkbeEkNvnH2sU2qmUx-jt64,2597
|
|
54
|
+
flowapp/templates/forms/machine_api_key.html,sha256=EH5ZTwm7mwKvZiWVo5o0av-cVNOvxVeFXprZOeIZfHk,1336
|
|
55
|
+
flowapp/templates/forms/macros.html,sha256=dABAOLTkKmq29kRv5iSX5Dyq-FzGxF-Dq88Y8r1S3Jc,4939
|
|
56
|
+
flowapp/templates/forms/org.html,sha256=hm3K98mxMolnQE9FNElb3A4mG7S6bHHSvLvrDIQkPVo,1043
|
|
57
|
+
flowapp/templates/forms/rtbh_rule.html,sha256=U3xLELl2FvY79NmKR_PNjsBMbWMLM0iwj80drPmSn1A,2143
|
|
58
|
+
flowapp/templates/forms/rule.html,sha256=-s-IW5i58umEcq2CO-nRlOSEDyuPM6G4wYH2gw27vYo,3557
|
|
59
|
+
flowapp/templates/forms/simple_form.html,sha256=LhdrgMN5LK93dzZQVbSsnW1LnupFrKAovBpujY3FgGA,291
|
|
60
|
+
flowapp/templates/forms/whitelist.html,sha256=tcnReDXxHLWyn6vo9eDx6qW5tI0dpSSKGTU0mxxoL-U,1723
|
|
61
|
+
flowapp/templates/layouts/default.html,sha256=tASL9aOWgrbj1f883uBu9dwFle06Qteh_VQDsWH2Saw,5352
|
|
62
|
+
flowapp/templates/pages/actions.html,sha256=PJC2_OBVhYuNNvF86gll0AOXVp5L5shHp0jTbOAEspU,987
|
|
63
|
+
flowapp/templates/pages/api_key.html,sha256=zFJQkRPHD8FYY8KkpSjcHuZiTG5T4Jue4HNuzBTY6jE,1552
|
|
64
|
+
flowapp/templates/pages/as_paths.html,sha256=wKXPbWk8AC3aj7ls12gt2BeVdf3Hrxw2vbTvPyleZuA,764
|
|
65
|
+
flowapp/templates/pages/communities.html,sha256=6VXxA2uLqOlffvNTvVy83j8Q9MI1kXgPDh_K6V84EIQ,1238
|
|
66
|
+
flowapp/templates/pages/dashboard_admin.html,sha256=t9sC25IkUpskOETGLCvMm8mPE2E12uag4qIiy_4eDUQ,812
|
|
67
|
+
flowapp/templates/pages/dashboard_search.html,sha256=l1lCII0YnQrGvG-AeKPJsCPkblX-4vaJYe4b4-CXNi0,646
|
|
68
|
+
flowapp/templates/pages/dashboard_user.html,sha256=Gk6S4Popz7_2V_aUkIR8PnkUyQrM-siDWSNq0CoJyjs,1506
|
|
69
|
+
flowapp/templates/pages/dashboard_view.html,sha256=ax6mVUlZnxhA_P--jRdokaYlzuXZJ7wYpX2cdUWmTV4,705
|
|
70
|
+
flowapp/templates/pages/dashboard_whois.html,sha256=P8HXKSVPjMGp1-100H5lpYBx2Hkjt1KmjmIexJSh6Z8,227
|
|
71
|
+
flowapp/templates/pages/limit_reached.html,sha256=fq9C4c2dkqvG7qSBeQmnM-LJurgGftJjQfoVIzSQHA4,1205
|
|
72
|
+
flowapp/templates/pages/logout.html,sha256=IfdqAWviubBvSVy6PqH5iWFwQ2udx1b6CVoGiplOTD0,179
|
|
73
|
+
flowapp/templates/pages/logs.html,sha256=pQ9SMh7-T5fKGHo5vpeVIr2JNO8btUZN3nX2aKaKSdg,1412
|
|
74
|
+
flowapp/templates/pages/machine_api_key.html,sha256=PmXNqW8ez8O6CBICDYVtcoMbPjaMncLiX8OEiZagKFs,1629
|
|
75
|
+
flowapp/templates/pages/org_modal.html,sha256=-ufMjA3sFBsNffmScFjl2Pn5VtdSdvH6qgpIoYtVQIQ,1058
|
|
76
|
+
flowapp/templates/pages/orgs.html,sha256=3K-HQPeRz-VkYHnbQ3lqPxPlvDEsYN3m8D_YnL_7KkI,1843
|
|
77
|
+
flowapp/templates/pages/submenu_dashboard.html,sha256=jhqh4OHB0qdrYt6KOrtKrxyw5zlAbG9jOWRtqCF2Bbg,2825
|
|
78
|
+
flowapp/templates/pages/submenu_dashboard_view.html,sha256=dJQLH9g_bpsHUlcDAwMgAMUai_PMRonrfAVmSk5BrYk,2695
|
|
79
|
+
flowapp/templates/pages/user_list.html,sha256=c-CrSp30-1e4fD63vyJgsGX9tKt4LFaHMmyj7-wQPqg,550
|
|
80
|
+
flowapp/templates/pages/users.html,sha256=b8f43HmtQ3d9_eqMJWhndGgsogT8O5OwmfHAORIm_l0,1233
|
|
81
|
+
flowapp/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
82
|
+
flowapp/tests/conftest.py,sha256=mnk22HOCTzKrr9xMeObfTYONujupzRX3rhqEhAQ0aAA,6178
|
|
83
|
+
flowapp/tests/rule_service_integration.py,sha256=t-G2q5w51LaMapJMV0zVXI7UwkeQ_9L_aDD1wp3SrIc,10441
|
|
84
|
+
flowapp/tests/test_api_auth.py,sha256=3Kmdt0Wgx8MG7oh-siYur3v0NSg8N8TsuEHHv60VGz8,1740
|
|
85
|
+
flowapp/tests/test_api_deprecated.py,sha256=cF2AB_2pU9EVidbCJsvC4hUYR76LuukY7j9X8VodnJA,657
|
|
86
|
+
flowapp/tests/test_api_v3.py,sha256=WrzMMd6F62ZXt5nv57to0l5XKmXOj4bq_PD0BqXj3Ys,17634
|
|
87
|
+
flowapp/tests/test_api_whitelist_integration.py,sha256=q09pfnlgn_83AALdfgOJUz1Pfr1bKfUZY4sZF8FQg1s,10276
|
|
88
|
+
flowapp/tests/test_flowapp.py,sha256=zLTz8VgHvSYElkPuahqsxeo2Iql_24r7ONYMUrswZJU,480
|
|
89
|
+
flowapp/tests/test_flowspec.py,sha256=p6WGtCvP15jY0MC9FzeZMhU5ENVr3QrxBVWcFqtW934,4364
|
|
90
|
+
flowapp/tests/test_forms.py,sha256=eshhW5Go3fPMZpsH6lo7BXcGf8wjZl4nHsiMUzWPvME,1989
|
|
91
|
+
flowapp/tests/test_forms_cl.py,sha256=4YSIA9PQMMv5JRhm6I3pfoigDGIsE1TWOS0cHdkXTSA,23415
|
|
92
|
+
flowapp/tests/test_login.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
|
+
flowapp/tests/test_models.py,sha256=V498wpSOaXQeAyxMB53vj-CM-WA9dYM4H6ls7f5E0MM,12431
|
|
94
|
+
flowapp/tests/test_rule_service.py,sha256=1m6sRUB2dhsGiL-9uKC28PAgOCpssZXqPuCZtAizPV0,24057
|
|
95
|
+
flowapp/tests/test_rule_service_reactivate_delete.py,sha256=1sB9Gw69HPS7G39TktNY3XxLTGpCJaWOjzixo8t-smE,19766
|
|
96
|
+
flowapp/tests/test_utils.py,sha256=uvp36rqUUPSLznn0QIEnGdq_z-wI0wHiaJB-9JpqMr8,1767
|
|
97
|
+
flowapp/tests/test_validators.py,sha256=GAvh_cfDbA8SjMS31r4HG6eH-UtYfnvE1s1FVAlHptg,17050
|
|
98
|
+
flowapp/tests/test_whitelist_common.py,sha256=3lVKLuITxLArvn34gtGRRCr04Ognxk21H_WWH-rYUZo,8956
|
|
99
|
+
flowapp/tests/test_whitelist_service.py,sha256=OVPPMVzx173eI9iLgNFQsZOxksXNpnBI9lz37xVjVCM,18018
|
|
100
|
+
flowapp/utils/__init__.py,sha256=54foaHPMucuH_sEIveccmk072OpIC0d2GjcIeXn-k7A,1025
|
|
101
|
+
flowapp/utils/app_factory.py,sha256=OnyeQPHNaDbtc8Sw4XEfvLsebpCzLQEwRRfR_BehirU,6924
|
|
102
|
+
flowapp/utils/base.py,sha256=05bftJcqcskWkkJB9hg2mpLNE4qOfFmBSJP6a0UOH1s,4292
|
|
103
|
+
flowapp/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
104
|
+
flowapp/views/admin.py,sha256=_9ocUzn_VOZ2eTwq8kiprMe7HK-Zi9DfGrMS3wsKffU,22624
|
|
105
|
+
flowapp/views/api_common.py,sha256=thJAH0fDxx5wbDvgYq4yT6mfw0itD0jsZv4r-mxyH3o,18291
|
|
106
|
+
flowapp/views/api_keys.py,sha256=QbsRqM59kU1Y6RS5b2AubEjQkaAdZTRuDL87hHt7Ao0,2921
|
|
107
|
+
flowapp/views/api_v1.py,sha256=Sd1m0s93pJd5VxKGz47V98AMzaCMOJl7cOm6tVXU2gI,478
|
|
108
|
+
flowapp/views/api_v2.py,sha256=LYNdEOLYiB7rKDvcliaqCzyt5y6snN2jBvfgO0IZ314,478
|
|
109
|
+
flowapp/views/api_v3.py,sha256=a-EsIWsdAy9fh8ooBrwtzb5jfVVcS5_WrESTV3f2qOg,4129
|
|
110
|
+
flowapp/views/dashboard.py,sha256=rzjAlXikFBVBx5p8g89D7MjCPSWIqhlDZxhObupcKyw,17727
|
|
111
|
+
flowapp/views/rules.py,sha256=1BFw9Vvg4ut9cxZ3wHRzULyY-K3soQS8MGODviL63ng,25121
|
|
112
|
+
flowapp/views/whitelist.py,sha256=DEUM8ZN6A8JqfOVQ48Kfgl1ltFQnXjsgABxwjQgkJgE,4109
|
|
113
|
+
exafs-1.1.6.dist-info/METADATA,sha256=ab7E0K2Ue8BUJHbPitRfNylTnwhhLEhw3ptBkeFOqHw,12530
|
|
114
|
+
exafs-1.1.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
115
|
+
exafs-1.1.6.dist-info/top_level.txt,sha256=5Smyf7AkIxgPFOB5k0nKSnfV_CxI-al2wYEF5adDMfw,8
|
|
116
|
+
exafs-1.1.6.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Jiri Vrany, Petr Adamec, Josef Verich, CESNET
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flowapp
|
flowapp/__about__.py
ADDED
flowapp/__init__.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from flask import Flask, redirect, render_template, session, url_for
|
|
3
|
+
|
|
4
|
+
from flask_sso import SSO
|
|
5
|
+
from flask_sqlalchemy import SQLAlchemy
|
|
6
|
+
from flask_wtf.csrf import CSRFProtect
|
|
7
|
+
from flask_migrate import Migrate
|
|
8
|
+
from flask_session import Session
|
|
9
|
+
from flasgger import Swagger
|
|
10
|
+
from werkzeug.middleware.proxy_fix import ProxyFix
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
from .__about__ import __version__
|
|
14
|
+
from .instance_config import InstanceConfig
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
db = SQLAlchemy()
|
|
18
|
+
migrate = Migrate()
|
|
19
|
+
csrf = CSRFProtect()
|
|
20
|
+
ext = SSO()
|
|
21
|
+
sess = Session()
|
|
22
|
+
swagger = Swagger(template_file="static/swagger.yml")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def create_app(config_object=None):
|
|
26
|
+
app = Flask(__name__)
|
|
27
|
+
|
|
28
|
+
# Load the default configuration for dashboard and main menu
|
|
29
|
+
app.config.from_object(InstanceConfig)
|
|
30
|
+
if config_object:
|
|
31
|
+
app.config.from_object(config_object)
|
|
32
|
+
|
|
33
|
+
# Allow override of instance config from external file
|
|
34
|
+
try:
|
|
35
|
+
app.config.from_pyfile("../instance_config_override.py", silent=False)
|
|
36
|
+
except FileNotFoundError:
|
|
37
|
+
pass # No override file, use defaults
|
|
38
|
+
|
|
39
|
+
app.config.setdefault("VERSION", __version__)
|
|
40
|
+
|
|
41
|
+
# SSO configuration
|
|
42
|
+
SSO_ATTRIBUTE_MAP = {
|
|
43
|
+
"eppn": (True, "eppn"),
|
|
44
|
+
}
|
|
45
|
+
app.config.setdefault("SSO_ATTRIBUTE_MAP", SSO_ATTRIBUTE_MAP)
|
|
46
|
+
app.config.setdefault("SSO_LOGIN_URL", "/login")
|
|
47
|
+
|
|
48
|
+
# extension init
|
|
49
|
+
migrate.init_app(app, db)
|
|
50
|
+
csrf.init_app(app)
|
|
51
|
+
|
|
52
|
+
# Init SSO
|
|
53
|
+
ext.init_app(app)
|
|
54
|
+
|
|
55
|
+
# Init swagger
|
|
56
|
+
swagger.init_app(app)
|
|
57
|
+
|
|
58
|
+
# handle proxy fix
|
|
59
|
+
if app.config.get("BEHIND_PROXY", False):
|
|
60
|
+
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1)
|
|
61
|
+
|
|
62
|
+
from flowapp import models, constants
|
|
63
|
+
from .auth import auth_required
|
|
64
|
+
|
|
65
|
+
# Register blueprints
|
|
66
|
+
from .utils import register_blueprints
|
|
67
|
+
|
|
68
|
+
register_blueprints(app, csrf)
|
|
69
|
+
|
|
70
|
+
# configure logging
|
|
71
|
+
from .utils import configure_logging
|
|
72
|
+
|
|
73
|
+
configure_logging(app)
|
|
74
|
+
|
|
75
|
+
# register error handlers
|
|
76
|
+
from .utils import register_error_handlers
|
|
77
|
+
|
|
78
|
+
register_error_handlers(app)
|
|
79
|
+
|
|
80
|
+
# register auth handlers
|
|
81
|
+
from .utils import register_auth_handlers
|
|
82
|
+
|
|
83
|
+
register_auth_handlers(app, ext)
|
|
84
|
+
|
|
85
|
+
@app.route("/")
|
|
86
|
+
@auth_required
|
|
87
|
+
def index():
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
rtype = session[constants.TYPE_ARG]
|
|
91
|
+
except KeyError:
|
|
92
|
+
rtype = next(iter(app.config["DASHBOARD"].keys()))
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
rstate = session[constants.RULE_ARG]
|
|
96
|
+
except KeyError:
|
|
97
|
+
rstate = "active"
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
sorter = session[constants.SORT_ARG]
|
|
101
|
+
except KeyError:
|
|
102
|
+
sorter = constants.DEFAULT_SORT
|
|
103
|
+
|
|
104
|
+
try:
|
|
105
|
+
orderer = session[constants.ORDER_ARG]
|
|
106
|
+
except KeyError:
|
|
107
|
+
orderer = constants.DEFAULT_ORDER
|
|
108
|
+
|
|
109
|
+
return redirect(
|
|
110
|
+
url_for(
|
|
111
|
+
"dashboard.index",
|
|
112
|
+
rtype=rtype,
|
|
113
|
+
rstate=rstate,
|
|
114
|
+
sort=sorter,
|
|
115
|
+
order=orderer,
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
@app.route("/select_org", defaults={"org_id": None})
|
|
120
|
+
@app.route("/select_org/<int:org_id>")
|
|
121
|
+
@auth_required
|
|
122
|
+
def select_org(org_id=None):
|
|
123
|
+
uuid = session.get("user_uuid")
|
|
124
|
+
user = db.session.query(models.User).filter_by(uuid=uuid).first()
|
|
125
|
+
|
|
126
|
+
if user is None:
|
|
127
|
+
return render_template("errors/404.html"), 404 # Handle missing user gracefully
|
|
128
|
+
|
|
129
|
+
orgs = user.organization
|
|
130
|
+
if org_id:
|
|
131
|
+
org = db.session.query(models.Organization).filter_by(id=org_id).first()
|
|
132
|
+
session["user_org_id"] = org.id
|
|
133
|
+
session["user_org"] = org.name
|
|
134
|
+
return redirect("/")
|
|
135
|
+
|
|
136
|
+
return render_template("pages/org_modal.html", orgs=orgs)
|
|
137
|
+
|
|
138
|
+
@app.teardown_appcontext
|
|
139
|
+
def shutdown_session(exception=None):
|
|
140
|
+
db.session.remove()
|
|
141
|
+
|
|
142
|
+
# register context processors and template filters
|
|
143
|
+
from .utils import register_context_processors, register_template_filters
|
|
144
|
+
|
|
145
|
+
register_context_processors(app)
|
|
146
|
+
register_template_filters(app)
|
|
147
|
+
|
|
148
|
+
return app
|