-
Notifications
You must be signed in to change notification settings - Fork 8
/
run.py
61 lines (50 loc) · 2.2 KB
/
run.py
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
import os
from vegadns.api import endpoint, app
from vegadns.api.endpoints import domain, domains, record, records, export
from vegadns.api.endpoints import domains_default_soa
from vegadns.api.endpoints import apikeys, apikey, groups, group
from vegadns.api.endpoints import token, groupmember, groupmembers, accounts
from vegadns.api.endpoints import domaingroupmap, domaingroupmaps
from vegadns.api.endpoints import default_record, default_records
from vegadns.api.endpoints import updatedata, account, login, logout
from vegadns.api.endpoints import healthcheck, audit_logs
from vegadns.api.endpoints import password_reset_token, password_reset_tokens
from vegadns.api.endpoints import locations, location
from vegadns.api.endpoints import location_prefixes, location_prefix
from vegadns.api.endpoints import swagger
from vegadns.api.endpoints import release_version
from vegadns.api.endpoints import oidc
from vegadns.api.config import config
from flask_pyoidc import OIDCAuthentication
from flask_pyoidc.provider_configuration import (
ProviderConfiguration,
ClientMetadata,
)
from flask_pyoidc.user_session import UserSession
profile = os.environ.get('PROFILE', None)
debug = True
if str(os.environ.get('DEBUG', True)).lower() not in ['true', '1']:
debug = False
app.DEBUG = debug
if profile:
from werkzeug.contrib.profiler import ProfilerMiddleware
app.config['PROFILE'] = True
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
if config.getboolean('oidc', 'enabled'):
SSO = 'SSO'
app.config['OIDC_REDIRECT_URI'] = config.get('oidc', 'redirect_uri')
SSO_CONFIG = ProviderConfiguration(
issuer=config.get('oidc', 'issuer'),
client_metadata=ClientMetadata(
config.get('oidc', 'client'), config.get('oidc', 'secret')
),
auth_request_params={
'scope':
[item.strip() for item in config.get('oidc', 'scope').split(',')]
}
)
app.config['SECRET_KEY'] = config.get('auth', 'cookie_secret')
app.config['OIDC_AUTH'] = OIDCAuthentication({SSO: SSO_CONFIG}, app)
app.config['OIDC_DECORATOR'] = app.config['OIDC_AUTH'].oidc_auth(SSO)
if __name__ == '__main__':
app.run(debug=debug, host='0.0.0.0')