Added support for Two-factor authentication for improving security. Fixes #6543

This commit is contained in:
Ashesh Vashi
2021-09-28 17:47:00 +05:30
committed by Akshay Joshi
parent c4db223a64
commit 787a441343
54 changed files with 2774 additions and 112 deletions
+21 -1
View File
@@ -19,7 +19,7 @@ from flask_security.views import _security
from flask_security.utils import get_post_logout_redirect, \
get_post_login_redirect, logout_user
from pgadmin import db, User
from pgadmin.model import db, User
from pgadmin.utils import PgAdminModule
from pgadmin.utils.constants import KERBEROS, INTERNAL, OAUTH2, LDAP
from pgadmin.authenticate.registry import AuthSourceRegistry
@@ -27,6 +27,26 @@ from pgadmin.authenticate.registry import AuthSourceRegistry
MODULE_NAME = 'authenticate'
auth_obj = None
_URL_WITH_NEXT_PARAM = "{0}?next={1}"
def get_logout_url() -> str:
"""
Returns the logout url based on the current authentication method.
Returns:
str: logout url
"""
BROWSER_INDEX = 'browser.index'
if config.SERVER_MODE and\
session['auth_source_manager']['current_source'] == \
KERBEROS:
return _URL_WITH_NEXT_PARAM.format(url_for(
'authenticate.kerberos_logout'), url_for(BROWSER_INDEX))
return _URL_WITH_NEXT_PARAM.format(
url_for('security.logout'), url_for(BROWSER_INDEX))
class AuthenticateModule(PgAdminModule):
def get_exposed_url_endpoints(self):