File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 4
4
from datetime import datetime , time , timedelta , date
5
5
from functools import wraps , lru_cache
6
6
from typing import Any , Callable , TypeVar , cast
7
+ from urllib .parse import urlparse
7
8
8
9
import requests
9
- from flask import session , redirect
10
+ from flask import session , redirect , request
10
11
11
12
from packet import auth , app , db , ldap
12
13
from packet .mail import send_start_packet_mail
@@ -64,6 +65,16 @@ def is_freshman_on_floor(rit_username: str) -> bool:
64
65
return False
65
66
66
67
68
+ @app .before_request
69
+ def before_reqest_callback () -> Any :
70
+ """
71
+ Pre-request function to ensure we're on the right URL before OIDC sees anything
72
+ """
73
+ if urlparse (request .base_url ).hostname != app .config ['SERVER_NAME' ]:
74
+ return redirect (request .base_url .replace (urlparse (request .base_url ).hostname ,
75
+ app .config ['SERVER_NAME' ]), code = 302 )
76
+ return None
77
+
67
78
def packet_auth (func : WrappedFunc ) -> WrappedFunc :
68
79
"""
69
80
Decorator for easily configuring oidc
You can’t perform that action at this time.
0 commit comments