Skip to content
Snippets Groups Projects
Verified Commit 1af20525 authored by Mark's avatar Mark
Browse files

Add docstring fir helper function

parent 7322f929
No related branches found
No related tags found
1 merge request!3Change login provider backend to graphql
Pipeline #557 passed with stages
in 5 minutes and 19 seconds
import re
def is_safe_url(url):
"""Checks if a url is safe
Check if a url is safe to be used in redirects. This function is used whenever the user
passes a redirect url to the application. In case of the login process the user passes
a url to the application via a HTTP-GET variable, namely `next`. Once the user successfully
authenticated, the url is used by the server to redirect to the page the user initially
requested. The url validation prevents attacks where an attacker creates links that
redirect users to malicious urls once they are loged in.
example: http://login-provider/login?next=malicious\.org/
Args:
url: Url that needs to be validated
Returns:
True if the url is trusted. False if not.
"""
safe_urls = [
"^[/]*$", # Home page
"^/\?login_challenge=[a-z|A-Z|0-9]+$" # Login challenge with alphanumeric code
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment