-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurl_security.py
More file actions
82 lines (52 loc) · 2.04 KB
/
Copy pathurl_security.py
File metadata and controls
82 lines (52 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
###########################################################
#
# Copyright (c) 2005, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
#
__all__ = ['RedirectSecurity', 'UrlSecurity']
from pyasm.common import *
from web_container import WebContainer
from widget import Html
class RedirectSecurity(Base):
'''class that manages the security for the url'''
def get_display(my):
web = WebContainer.get_web()
# get the request uri
request_uri = web.get_env("REQUEST_URI")
security = WebContainer.get_security()
groups = security.get_groups()
# go through each group and find a redirect. Take the first one
for group in groups:
# find out if the person user has a redirect which confines them
# to a particular address
redirect = group.get_value("redirect_url")
# prevent mistaken infinte loops
redirect = redirect.strip()
if not redirect:
continue
if request_uri.find(redirect) == -1:
# draw the actual page
html = Html()
html.writeln('<HEAD>')
html.writeln('<META HTTP-EQUIV="Refresh" CONTENT="0; URL=%s"' % redirect)
html.writeln('</HEAD>')
return html
return None
class UrlSecurity(Base):
def get_display(my):
html = None
url = WebContainer.get_web().get_request_url().to_string()
# check the url security
security = WebContainer.get_security()
if not security.check_access("url", url, "view"):
html = Html()
# should probably just use this widget instead of redirecting
redirect = "/tactic/Error403"
html.writeln("<script>document.location = '%s'</script>" % redirect)
return html