-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextensions.py
43 lines (38 loc) · 1.32 KB
/
extensions.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
from flask_session import Session
from flask_wtf.csrf import CSRFProtect
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
from flask_sqlalchemy import SQLAlchemy
from authlib.integrations.flask_client import OAuth
import os
# Initialize extensions
sess = Session()
csrf = CSRFProtect()
limiter = Limiter(
get_remote_address, # This will limit based on the IP address of the requester
default_limits=["200 per day", "50 per hour"] # Set default rate limits
)
#the db
db = SQLAlchemy()
#oauth of google
oauth = OAuth()
google = oauth.register(
name='google',
client_id=os.getenv("GOOGLE_CLIENT_ID"),
client_secret=os.getenv("GOOGLE_CLIENT_SECRET"),
access_token_url='https://accounts.google.com/o/oauth2/token',
access_token_params=None,
authorize_url='https://accounts.google.com/o/oauth2/auth',
authorize_params=None,
api_base_url='https://www.googleapis.com/oauth2/v1/',
userinfo_endpoint='https://openidconnect.googleapis.com/v1/userinfo',
client_kwargs={'scope': 'email profile'},
server_metadata_url='https://accounts.google.com/.well-known/openid-configuration'
)
#defining the extentions on all of the app
def init_extensions(app):
sess.init_app(app)
csrf.init_app(app)
limiter.init_app(app)
db.init_app(app)
oauth.init_app(app)