forked from enviPath/enviPy
wip
This commit is contained in:
@ -9,11 +9,7 @@
|
|||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
this.isSubmitting = false;
|
this.isSubmitting = false;
|
||||||
this.selectedType = '';
|
this.packageClassification = null;
|
||||||
this.buildAppDomain = false;
|
|
||||||
this.requiresRulePackages = false;
|
|
||||||
this.requiresDataPackages = false;
|
|
||||||
this.additional_parameters = null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setFormData(data) {
|
setFormData(data) {
|
||||||
|
|||||||
@ -451,5 +451,26 @@ if PES_API_MAPPING:
|
|||||||
else:
|
else:
|
||||||
PES_API_MAPPING = {}
|
PES_API_MAPPING = {}
|
||||||
|
|
||||||
# AD Group Mapping
|
# Entra Groups
|
||||||
|
ENTRA_GROUPS = os.environ.get("ENTRA_GROUPS", None)
|
||||||
|
if ENTRA_GROUPS:
|
||||||
|
import json
|
||||||
|
ENTRA_GROUPS = json.loads(ENTRA_GROUPS)
|
||||||
|
else:
|
||||||
|
ENTRA_GROUPS = {}
|
||||||
|
|
||||||
|
ENTRA_SECRET_GROUPS = os.environ.get("ENTRA_SECRET_GROUPS", None)
|
||||||
|
if ENTRA_SECRET_GROUPS:
|
||||||
|
import json
|
||||||
|
ENTRA_SECRET_GROUPS = json.loads(ENTRA_SECRET_GROUPS)
|
||||||
|
else:
|
||||||
|
ENTRA_SECRET_GROUPS = {}
|
||||||
|
|
||||||
|
# PES Data Pools vs Entra Mapping
|
||||||
|
DATA_POOL_MAPPING = os.environ.get("DATA_POOL_MAPPING", None)
|
||||||
|
if DATA_POOL_MAPPING:
|
||||||
|
import json
|
||||||
|
DATA_POOL_MAPPING = json.loads(DATA_POOL_MAPPING)
|
||||||
|
else:
|
||||||
|
DATA_POOL_MAPPING = {}
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,11 @@ if "migration" in s.INSTALLED_APPS:
|
|||||||
if s.MS_ENTRA_ENABLED:
|
if s.MS_ENTRA_ENABLED:
|
||||||
urlpatterns.append(path(f"{PATH_PREFIX}", include("epauth.urls")))
|
urlpatterns.append(path(f"{PATH_PREFIX}", include("epauth.urls")))
|
||||||
|
|
||||||
|
if s.TENANT != "public":
|
||||||
|
urlpatterns.append(
|
||||||
|
path(f"{PATH_PREFIX}", include(f"{s.TENANT}.urls"))
|
||||||
|
)
|
||||||
|
|
||||||
# Custom error handlers
|
# Custom error handlers
|
||||||
handler400 = "epdb.views.handler400"
|
handler400 = "epdb.views.handler400"
|
||||||
handler403 = "epdb.views.handler403"
|
handler403 = "epdb.views.handler403"
|
||||||
|
|||||||
@ -4,8 +4,8 @@ from django.contrib.auth import login
|
|||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from epdb.logic import UserManager
|
from epdb.logic import UserManager, GroupManager
|
||||||
|
from epdb.models import Group
|
||||||
|
|
||||||
def entra_login(request):
|
def entra_login(request):
|
||||||
msal_app = msal.ConfidentialClientApplication(
|
msal_app = msal.ConfidentialClientApplication(
|
||||||
@ -35,11 +35,29 @@ def entra_callback(request):
|
|||||||
|
|
||||||
# Acquire token using the flow and callback request
|
# Acquire token using the flow and callback request
|
||||||
result = msal_app.acquire_token_by_auth_code_flow(flow, request.GET)
|
result = msal_app.acquire_token_by_auth_code_flow(flow, request.GET)
|
||||||
|
print(result)
|
||||||
|
# if "error" in result:
|
||||||
|
# {'correlation_id': '626f511b-5230-4d06-9ffd-d89a764082c6',
|
||||||
|
# 'error': 'invalid_client',
|
||||||
|
# 'error_codes': [7000222],
|
||||||
|
# 'error_description': 'AADSTS7000222: The provided client secret keys for app '
|
||||||
|
# "'35c75dfb-bd15-493d-b4e9-af847f2df894' are expired. "
|
||||||
|
# 'Visit the Azure portal to create new keys for your app: '
|
||||||
|
# 'https://aka.ms/NewClientSecret, or consider using '
|
||||||
|
# 'certificate credentials for added security: '
|
||||||
|
# 'https://aka.ms/certCreds. Trace ID: '
|
||||||
|
# '30ba1c58-c949-4432-9ed6-3b6136856700 Correlation ID: '
|
||||||
|
# '626f511b-5230-4d06-9ffd-d89a764082c6 Timestamp: '
|
||||||
|
# '2026-04-15 08:21:15Z',
|
||||||
|
# 'error_uri': 'https://login.microsoftonline.com/error?code=7000222',
|
||||||
|
# 'timestamp': '2026-04-15 08:21:15Z',
|
||||||
|
# 'trace_id': '30ba1c58-c949-4432-9ed6-3b6136856700'}
|
||||||
|
# return redirect("/")
|
||||||
|
|
||||||
claims = result["id_token_claims"]
|
claims = result["id_token_claims"]
|
||||||
|
|
||||||
user_name = claims["name"]
|
user_name = claims["name"]
|
||||||
user_email = claims["emailaddress"]
|
user_email = claims.get("emailaddress", claims["email"])
|
||||||
user_oid = claims["oid"]
|
user_oid = claims["oid"]
|
||||||
|
|
||||||
# Get implementing class
|
# Get implementing class
|
||||||
@ -57,4 +75,28 @@ def entra_callback(request):
|
|||||||
|
|
||||||
login(request, u)
|
login(request, u)
|
||||||
|
|
||||||
return redirect("/") # Handle errors
|
# EDIT START
|
||||||
|
# Ensure groups exists in eP
|
||||||
|
for id, name in s.ENTRA_SECRET_GROUPS.items():
|
||||||
|
if not Group.objects.filter(uuid=id).exists():
|
||||||
|
g = GroupManager.create_group(User.objects.get(username="admin"), name, f"Synced Entra Group {name} ", uuid=id)
|
||||||
|
else:
|
||||||
|
g = Group.objects.get(uuid=id)
|
||||||
|
# Ensure its secret
|
||||||
|
g.secret = True
|
||||||
|
g.save()
|
||||||
|
|
||||||
|
for id, name in s.ENTRA_GROUPS.items():
|
||||||
|
if not Group.objects.filter(uuid=id).exists():
|
||||||
|
g = GroupManager.create_group(User.objects.get(username="admin"), name, f"Synced Entra Group {name} ", uuid=id)
|
||||||
|
else:
|
||||||
|
g = Group.objects.get(uuid=id)
|
||||||
|
|
||||||
|
for group_uuid in claims.get("groups", []):
|
||||||
|
if Group.objects.filter(uuid=group_uuid).exists():
|
||||||
|
g = Group.objects.get(uuid=group_uuid)
|
||||||
|
g.user_member.add(u)
|
||||||
|
|
||||||
|
# EDIT END
|
||||||
|
|
||||||
|
return redirect(s.SERVER_URL) # Handle errors
|
||||||
|
|||||||
@ -264,8 +264,12 @@ class GroupManager(object):
|
|||||||
return bool(re.findall(GroupManager.group_pattern, url))
|
return bool(re.findall(GroupManager.group_pattern, url))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_group(current_user, name, description):
|
def create_group(current_user, name, description, *args, **kwargs):
|
||||||
g = Group()
|
g = Group()
|
||||||
|
|
||||||
|
if "uuid" in kwargs:
|
||||||
|
g.uuid = kwargs["uuid"]
|
||||||
|
|
||||||
# Clean for potential XSS
|
# Clean for potential XSS
|
||||||
g.name = nh3.clean(name, tags=s.ALLOWED_HTML_TAGS).strip()
|
g.name = nh3.clean(name, tags=s.ALLOWED_HTML_TAGS).strip()
|
||||||
g.description = nh3.clean(description, tags=s.ALLOWED_HTML_TAGS).strip()
|
g.description = nh3.clean(description, tags=s.ALLOWED_HTML_TAGS).strip()
|
||||||
|
|||||||
@ -171,12 +171,19 @@ class FormatConverter(object):
|
|||||||
try:
|
try:
|
||||||
Chem.Kekulize(mol)
|
Chem.Kekulize(mol)
|
||||||
except Exception:
|
except Exception:
|
||||||
mc = Chem.Mol(mol.ToBinary())
|
mol = Chem.Mol(mol.ToBinary())
|
||||||
|
|
||||||
if not mc.GetNumConformers():
|
if not mol.GetNumConformers():
|
||||||
Chem.rdDepictor.Compute2DCoords(mc)
|
Chem.rdDepictor.Compute2DCoords(mol)
|
||||||
|
|
||||||
pass
|
drawer = rdMolDraw2D.MolDraw2DCairo(*mol_size)
|
||||||
|
opts = drawer.drawOptions()
|
||||||
|
|
||||||
|
opts.clearBackground = False
|
||||||
|
drawer.DrawMolecule(mol)
|
||||||
|
drawer.FinishDrawing()
|
||||||
|
|
||||||
|
return drawer.GetDrawingText()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize(smiles):
|
def normalize(smiles):
|
||||||
|
|||||||
Reference in New Issue
Block a user