Skip to content

Commit 1c640e2

Browse files
authored
Merge pull request #77 from CESNET/develop
1.2.0 version
2 parents 04286d9 + fdab2a4 commit 1c640e2

37 files changed

Lines changed: 110 additions & 63 deletions

config.example.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ class Config:
1010
FLOWSPEC6_MAX_RULES = 9000
1111
RTBH_MAX_RULES = 100000
1212

13-
# Flask debugging
14-
DEBUG = True
15-
# Flask testing
16-
TESTING = False
17-
1813
# Choose your authentication method and set it to True here or
1914
# the production / development config
2015
# SSO auth enabled
@@ -104,6 +99,8 @@ class DevelopmentConfig(Config):
10499
SQLALCHEMY_DATABASE_URI = "Your Local Database URI"
105100
LOCAL_IP = "127.0.0.1"
106101
LOCAL_IP6 = "::ffff:127.0.0.1"
102+
103+
# Debug and Devel mode enabled
107104
DEBUG = True
108105
DEVEL = True
109106

flowapp/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.1.9"
1+
__version__ = "1.2.0"
22
__title__ = "ExaFS"
33
__description__ = "Tool for creation, validation, and execution of ExaBGP messages."
44
__author__ = "CESNET / Jiri Vrany, Petr Adamec, Josef Verich, Jakub Man"

flowapp/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
import os
3-
from flask import Flask, redirect, render_template, session, url_for
2+
from flask import Flask, redirect, render_template, session, url_for, flash
43

54
from flask_sso import SSO
65
from flask_sqlalchemy import SQLAlchemy
@@ -128,11 +127,15 @@ def select_org(org_id=None):
128127
user = db.session.query(models.User).filter_by(uuid=uuid).first()
129128

130129
if user is None:
131-
return render_template("errors/404.html"), 404 # Handle missing user gracefully
130+
return render_template("errors/404.html"), 404
132131

133132
orgs = user.organization
134133
if org_id:
135-
org = db.session.query(models.Organization).filter_by(id=org_id).first()
134+
# Verify user belongs to this organization
135+
org = user.organization.filter_by(id=org_id).first()
136+
if not org:
137+
flash("You don't have access to this organization", "alert-danger")
138+
return redirect(url_for("index"))
136139
session["user_org_id"] = org.id
137140
session["user_org"] = org.name
138141
return redirect("/")

flowapp/auth.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ def decorated(*args, **kwargs):
4848
def user_or_admin_required(f):
4949
"""
5050
decorator for admin/user endpoints
51+
Allows access if the user has at least one role with ID > 1 (user or admin)
52+
Role IDs: 1=view (read-only), 2=user (can create/edit), 3=admin
5153
"""
5254

5355
@wraps(f)
5456
def decorated(*args, **kwargs):
55-
if not all(i > 1 for i in session["user_role_ids"]):
57+
if not any(i > 1 for i in session["user_role_ids"]):
5658
return redirect(url_for("index"))
5759
return f(*args, **kwargs)
5860

flowapp/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
MAX_PORT = 65535
3636
MAX_PACKET = 9216
3737

38-
IPV6_NEXT_HEADER = {"tcp": "tcp", "udp": "udp", "icmp": "58", "all": ""}
38+
IPV6_NEXT_HEADER = {"tcp": "tcp", "udp": "udp", "icmp": "58", "gre": "gre", "all": ""}
3939

40-
IPV4_PROTOCOL = {"tcp": "tcp", "udp": "udp", "icmp": "icmp", "all": ""}
40+
IPV4_PROTOCOL = {"tcp": "tcp", "udp": "udp", "icmp": "icmp", "gre": "gre", "all": ""}
4141

4242
IPV4_FRAGMENT = {
4343
"dont": "dont-fragment",

flowapp/instance_config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,14 @@ class InstanceConfig:
102102
"divide_before": True,
103103
},
104104
{"name": "Add action", "url": "admin.action"},
105-
{"name": "RTBH Communities", "url": "admin.communities"},
105+
{
106+
"name": "RTBH Communities",
107+
"url": "admin.communities",
108+
"divide_before": True,
109+
},
106110
{"name": "Add RTBH Comm.", "url": "admin.community"},
111+
{"name": "AS Paths", "url": "admin.as_paths"},
112+
{"name": "Add AS Path", "url": "admin.as_path"},
107113
],
108114
}
109115
DASHBOARD = {

flowapp/templates/macros.html

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@
5252
<a class="btn btn-info btn-sm" href="{{ url_for('rules.reactivate_rule', rule_type=rtype_int, rule_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="set expiration">
5353
<i class="bi bi-clock table-icon"></i>
5454
</a>
55-
<a class="btn btn-danger btn-sm" href="{{ url_for('rules.delete_rule', rule_type=rtype_int, rule_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
56-
<i class="bi bi-x-lg"></i>
57-
</a>
55+
<form method="POST" action="{{ url_for('rules.delete_rule', rule_type=rtype_int, rule_id=rule.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this rule?');">
56+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
57+
<button type="submit" class="btn btn-danger btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
58+
<i class="bi bi-x-lg"></i>
59+
</button>
60+
</form>
5861
{% endif %}
5962
{% if rule.comment %}
6063
<button type="button" class="btn btn-info btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="{{ rule.comment }}">
@@ -108,14 +111,20 @@
108111
<a class="btn btn-info btn-sm" href="{{ url_for('rules.reactivate_rule', rule_type=1, rule_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="set expiration">
109112
<i class="bi bi-clock table-icon"></i>
110113
</a>
111-
<a class="btn btn-danger btn-sm" href="{{ url_for('rules.delete_rule', rule_type=1, rule_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
112-
<i class="bi bi-x-lg"></i>
113-
</a>
114-
{% if rule.community.id in allowed_communities %}
115-
<a class="btn btn-success btn-sm" href="{{ url_for('rules.delete_and_whitelist', rule_type=1, rule_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="whitelist and delete">
116-
<i class="bi bi-shield-x"></i>
117-
</a>
118-
{% endif %}
114+
<form method="POST" action="{{ url_for('rules.delete_rule', rule_type=1, rule_id=rule.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this rule?');">
115+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
116+
<button type="submit" class="btn btn-danger btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
117+
<i class="bi bi-x-lg"></i>
118+
</button>
119+
</form>
120+
{% if rule.community.id in allowed_communities %}
121+
<form method="POST" action="{{ url_for('rules.delete_and_whitelist', rule_type=1, rule_id=rule.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to whitelist and delete this rule?');">
122+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
123+
<button type="submit" class="btn btn-success btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="whitelist and delete">
124+
<i class="bi bi-shield-x"></i>
125+
</button>
126+
</form>
127+
{% endif %}
119128
{% endif %}
120129
{% if rule.comment %}
121130
<button type="button" class="btn btn-info btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="{{ rule.comment }}">
@@ -153,9 +162,12 @@
153162
<a class="btn btn-info btn-sm" href="{{ url_for('whitelist.reactivate', wl_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="set expiration">
154163
<i class="bi bi-clock table-icon"></i>
155164
</a>
156-
<a class="btn btn-danger btn-sm" href="{{ url_for('whitelist.delete', wl_id=rule.id) }}" role="button" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
157-
<i class="bi bi-x-lg"></i>
158-
</a>
165+
<form method="POST" action="{{ url_for('whitelist.delete', wl_id=rule.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this whitelist?');">
166+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
167+
<button type="submit" class="btn btn-danger btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="delete">
168+
<i class="bi bi-x-lg"></i>
169+
</button>
170+
</form>
159171
{% endif %}
160172
{% if rule.comment %}
161173
<button type="button" class="btn btn-info btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="{{ rule.comment }}">

flowapp/templates/pages/actions.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@
2525
<a class="btn btn-info btn-sm" href="{{ url_for('admin.edit_action', action_id=action.id) }}" role="button">
2626
<i class="bi bi-pen"></i>
2727
</a>
28-
<a class="btn btn-danger btn-sm" href="{{ url_for('admin.delete_action', action_id=action.id) }}" role="button">
29-
<i class="bi bi-x-lg"></i>
30-
</a>
28+
<form method="POST" action="{{ url_for('admin.delete_action', action_id=action.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this action?');">
29+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
30+
<button type="submit" class="btn btn-danger btn-sm">
31+
<i class="bi bi-x-lg"></i>
32+
</button>
33+
</form>
3134
</td>
3235
</tr>
3336
{% endfor %}

flowapp/templates/pages/as_paths.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
<a class="btn btn-info btn-sm" href="{{ url_for('admin.edit_as_path', path_id=pth.id) }}" role="button">
1818
<i class="bi bi-pen"></i>
1919
</a>
20-
<a class="btn btn-danger btn-sm" href="{{ url_for('admin.delete_as_path', path_id=pth.id) }}" role="button">
21-
<i class="bi bi-x-lg"></i>
22-
</a>
20+
<form method="POST" action="{{ url_for('admin.delete_as_path', path_id=pth.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this AS path?');">
21+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
22+
<button type="submit" class="btn btn-danger btn-sm">
23+
<i class="bi bi-x-lg"></i>
24+
</button>
25+
</form>
2326
</td>
2427
</tr>
2528
{% endfor %}

flowapp/templates/pages/communities.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
<a class="btn btn-info btn-sm" href="{{ url_for('admin.edit_community', community_id=community.id) }}" role="button">
3232
<i class="bi bi-pen"></i>
3333
</a>
34-
<a class="btn btn-danger btn-sm" href="{{ url_for('admin.delete_community', community_id=community.id) }}" role="button">
35-
<i class="bi bi-x-lg"></i>
36-
</a>
34+
<form method="POST" action="{{ url_for('admin.delete_community', community_id=community.id) }}" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this community?');">
35+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
36+
<button type="submit" class="btn btn-danger btn-sm">
37+
<i class="bi bi-x-lg"></i>
38+
</button>
39+
</form>
3740
</td>
3841
</tr>
3942
{% endfor %}

0 commit comments

Comments
 (0)