Skip to content

Commit

Permalink
add user accounts and remove dependence on casbin, allowing projects …
Browse files Browse the repository at this point in the history
…to pull it in
  • Loading branch information
philtweir committed Nov 18, 2023
1 parent 7fac9ea commit 56c5b8c
Show file tree
Hide file tree
Showing 12 changed files with 531 additions and 53 deletions.
2 changes: 0 additions & 2 deletions arches/app/media/js/views/user-profile-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ define([
}).done(function(data) {
var koType;
var user = Object.keys(data);
console.log(user);
console.log(data);
if (user.length == 1) {
const userId = user[0];
Object.values(data[userId]).forEach(function(role) {
Expand Down
1 change: 1 addition & 0 deletions arches/app/models/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def check_default_configs(default_configs, configs):

if "functions_x_graphs" in args[0]:
for function in args[0]["functions_x_graphs"]:
print("!!!!!")
function_x_graph_config = function["config"]
default_config = models.Function.objects.get(functionid=function["function_id"]).defaultconfig
function["config"] = check_default_configs(default_config, function_x_graph_config)
Expand Down

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions arches/app/models/migrations/9605_merge_20231031_0903.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.2.19 on 2023-10-31 09:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('models', '9477_fix_for_spatial_view_dbf_function_edtf_displaying_null'),
('models', '9604_relational_data_model_handle_user_accounts'),
]

operations = [
]
15 changes: 0 additions & 15 deletions arches/app/permissions/casbin.conf

This file was deleted.

45 changes: 45 additions & 0 deletions arches/app/templates/views/components/datatypes/user_account.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% load i18n %}
<!-- ko if: $data.search -->
<div class="col-md-4 col-lg-3">
<select
class="resources"
data-bind="
value: op,
chosen: {width: '100%', disable_search_threshold: 15},
optionsText: 'text',
optionsValue: 'value',
options: [
{ text: $root.translations.like, value: '~' },
{ text: $root.translations.notLike, value: '!~' },
{ text: $root.translations.equals, value: 'eq' },
{ text: $root.translations.not, value: '!eq' },
{ text: $root.translations.hasNoValue, value: 'null' },
{ text: $root.translations.hasAnyValue, value: 'not_null' },
],
attr: {'aria-label': $root.translations.searchCriteria},
"
></select>
</div>
<div class="col-md-3 col-lg-2">
<select
data-bind="
options: languages,
optionsText: function(item){return item.name + ' (' + item.code + ')'},
value: language, chosen:{width:'100%'},
attr: {'aria-label': $root.translations.languages}
"
></select>
</div>
<div class="col-md-5 col-lg-7" data-bind="visible: op() !== 'null' && op() !== 'not_null'">
<input
type="text"
class="form-control input-lg"
style="height: 36px;"
data-bind="
attr: {placeholder: $root.translations.name, 'aria-label': $root.translations.name},
value: searchValue,
valueUpdate: 'keyup'
"
>
</div>
<!-- /ko -->
47 changes: 47 additions & 0 deletions arches/app/templates/views/components/widgets/user_account.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "views/components/widgets/base.htm" %}
{% load template_tags %}
{% load i18n %}

{% block form %}
<div class="row widget-wrapper" data-bind="let: {uid: Math.random().toString()}">
<!-- ko if: node -->
<i data-bind="css: {'ion-asterisk widget-label-required': node.isrequired}"></i>
<!-- /ko -->
<div class="form-group">
<div class="col-xs-12">
<input type="text" data-bind="
textInput: value,
attr: {placeholder: placeholder, disabled: disabled, 'aria-label': label}"
class="form-control input-lg widget-input">
</div>
</div>
</div>
{% endblock form %}

{% block config_form %}
<div class="control-label">
<span data-bind="text: $root.translations.placeholder"></span>
</div>
<div class="col-xs-12 pad-no crud-widget-container">
<input
class="form-control input-md widget-input"
data-bind="
attr: {placeholder: $root.translations.placeholder, 'aria-label': $root.translations.placeholder},
textInput: placeholder
"
>
</div>

<div class="control-label">
<span data-bind="text: $root.translations.defaultValue"></span>
</div>
<div class="col-xs-12 pad-no crud-widget-container">
<input
class="form-control input-md widget-input"
data-bind="
attr: {placeholder: $root.translations.defaultValue, 'aria-label': $root.translations.defaultValue},
textInput: defaultValue
"
>
</div>
{% endblock config_form %}
2 changes: 2 additions & 0 deletions arches/app/utils/data_management/resource_graphs/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def check_default_configs(default_configs, configs):
logger.exception(ge)
errors.append(ge)
except Exception as e:
import traceback
traceback.print_exc()
errors.append(str(e))
logger.exception(e)
# try/except block here until all graphs have a resource_2_resource_constraints object.
Expand Down
2 changes: 2 additions & 0 deletions arches/app/utils/data_management/resources/importer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import os
import sys
import csv
Expand Down Expand Up @@ -65,6 +66,7 @@ def __init__(self, file=None, mapping_file=None, relations_file=None):
if mapping_file is None:
try:
mapping_file_base = os.path.splitext(file[0])[0]
mapping_file_base = re.sub(r"_[0-9]+$", "", mapping_file_base)
mapping_file = [f"{mapping_file_base}.mapping"]
except:
print("*" * 80)
Expand Down
25 changes: 15 additions & 10 deletions arches/management/commands/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,16 +297,21 @@ def handle(self, *args, **options):
concept_count = models.Value.objects.count()
relation_count = models.ResourceXResource.objects.count()

self.import_business_data(
options["source"],
options["config_file"],
options["overwrite"],
options["bulk_load"],
options["create_concepts"],
use_multiprocessing=options["use_multiprocessing"],
force=options["yes"],
prevent_indexing=prevent_indexing,
)
try:
self.import_business_data(
options["source"],
options["config_file"],
options["overwrite"],
options["bulk_load"],
options["create_concepts"],
use_multiprocessing=options["use_multiprocessing"],
force=options["yes"],
prevent_indexing=prevent_indexing,
)
except Exception as exc:
import traceback
traceback.print_exception()
raise

if defer_indexing and not prevent_indexing:
# index concepts if new concepts created
Expand Down
29 changes: 3 additions & 26 deletions arches/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
AUTHENTICATION_BACKENDS = (
"arches.app.utils.email_auth_backend.EmailAuthenticationBackend",
"oauth2_provider.backends.OAuth2Backend",
"dauthz.backends.CasbinBackend",
#"dauthz.backends.CasbinBackend",
"django.contrib.auth.backends.ModelBackend", # this is default
#"arches.app.utils.permission_backend.PermissionBackend",
"arches.app.utils.external_oauth_backend.ExternalOauthAuthenticationBackend",
Expand All @@ -350,7 +350,7 @@
"oauth2_provider",
"django_celery_results",
"compressor",
"dauthz.apps.DauthzConfig"
#"dauthz.apps.DauthzConfig"
)

MIDDLEWARE = [
Expand All @@ -366,7 +366,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
# "django.middleware.clickjacking.XFrameOptionsMiddleware",
"dauthz.middlewares.request_middleware.RequestMiddleware",
#"dauthz.middlewares.request_middleware.RequestMiddleware",
"arches.app.utils.middleware.SetAnonymousUser",
]

Expand Down Expand Up @@ -747,29 +747,6 @@ def JSON_LD_FIX_DATA_FUNCTION(data, jsdata, model):
return jsdata

PERMISSION_FRAMEWORK = "arches_standard.ArchesStandardPermissionFramework"
CASBIN_MODEL = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app', 'permissions', 'casbin.conf')

DAUTHZ = {
# DEFAULT Dauthz enforcer
"DEFAULT": {
# Casbin model setting.
"MODEL": {
# Available Settings: "file", "text"
"CONFIG_TYPE": "file",
"CONFIG_FILE_PATH": CASBIN_MODEL,
"CONFIG_TEXT": "",
},
# Casbin adapter .
"ADAPTER": {
"NAME": "casbin_adapter.adapter.Adapter",
# 'OPTION_1': '',
},
"LOG": {
# Changes whether Dauthz will log messages to the Logger.
"ENABLED": False,
},
},
}

##########################################
### END RUN TIME CONFIGURABLE SETTINGS ###
Expand Down
2 changes: 2 additions & 0 deletions arches/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@
from arches.app.models import permissions

settings.update_from_db()
import logging
logging.disable(logging.NOTSET)

0 comments on commit 56c5b8c

Please sign in to comment.