-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
78 lines (63 loc) · 2.24 KB
/
app.py
File metadata and controls
78 lines (63 loc) · 2.24 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
76
77
78
from flask import Flask
import logging
import time
from tests.openid_configuration import OpenIdConfiguration
from tests.auth_code_flow import AuthCodeFlow
from tests.token_refresh_flow import TokenRefreshFlow
from tests.access_token_available import AccessTokenAvailable
from shared.auth_provider import AuthProvider
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s"
)
app = Flask(__name__)
auth_provider = AuthProvider()
@app.route("/auth/openid-configuration")
def serve_openid_configuration():
logging.info("Serving OpenID configuration test")
openid_configuration = OpenIdConfiguration(auth_provider)
start_time = time.time()
result = openid_configuration.run_test()
end_time = time.time()
logging.info(
f"OpenID configuration test completed in {end_time - start_time:.2f} seconds"
)
return result
@app.route("/auth/auth-code")
def serve_auth_code():
logging.info("Serving auth code flow test")
auth_code_flow = AuthCodeFlow(auth_provider)
start_time = time.time()
result = auth_code_flow.run_test()
end_time = time.time()
logging.info(
f"Auth code flow test completed in {end_time - start_time:.2f} seconds"
)
return result
@app.route("/auth/refresh-token")
def serve_token_refresh():
logging.info("Serving token refresh flow test")
token_refresh_flow = TokenRefreshFlow(auth_provider)
start_time = time.time()
result = token_refresh_flow.run_test()
end_time = time.time()
logging.info(
f"Token refresh flow test completed in {end_time - start_time:.2f} seconds"
)
return result
@app.route("/auth/access-token")
def serve_access_token():
logging.info("Serving access token availability test")
access_token_available = AccessTokenAvailable(auth_provider)
start_time = time.time()
result = access_token_available.run_test()
end_time = time.time()
logging.info(
f"Access token availability test completed in {end_time - start_time:.2f} seconds"
)
return result
@app.route("/auth/callback")
def serve_callback():
logging.info("Received callback request")
return "Callback received"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)