forked from r00tstici/CTFd-SSO-plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
32 lines (26 loc) · 986 Bytes
/
models.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
from CTFd.models import db
class OAuthClients(db.Model):
__tablename__ = "oauth_clients"
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text)
client_id = db.Column(db.Text)
client_secret = db.Column(db.Text)
access_token_url = db.Column(db.Text)
authorize_url = db.Column(db.Text)
api_base_url = db.Column(db.Text)
# In a later update you will be able to customize the login button
color = db.Column(db.Text)
icon = db.Column(db.Text)
def register(self, oauth):
oauth.register(
name=self.id,
client_id=self.client_id,
client_secret=self.client_secret,
access_token_url=self.access_token_url,
authorize_url=self.authorize_url,
api_base_url=self.api_base_url,
client_kwargs={'scope': 'profile roles'}
)
def disconnect(self, oauth):
oauth._registry[self.id] = None
oauth._clients[self.id] = None