Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rights Engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Polaris
Rights Engine
Commits
173bcd82
Commit
173bcd82
authored
1 year ago
by
Benjamin Ledel
Browse files
Options
Downloads
Patches
Plain Diff
* xapi and debugging tools
parent
5c0b2b97
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/backend/settings.py
+1
-0
1 addition, 0 deletions
src/backend/settings.py
src/static/xapi_statement.schema.json
+1
-7
1 addition, 7 deletions
src/static/xapi_statement.schema.json
src/xapi/views.py
+11
-6
11 additions, 6 deletions
src/xapi/views.py
with
13 additions
and
13 deletions
src/backend/settings.py
+
1
−
0
View file @
173bcd82
...
...
@@ -44,6 +44,7 @@ ANALYTICS_RESULTS_RETENTION = env("ANALYTICS_RESULTS_RETENTION", default=31)
ALLOWED_HOSTS
=
[
"
*
"
]
IDP_ENABLED
=
env
(
"
IDP_ENABLED
"
)
SHOW_XAPI_STATEMENTS
=
env
(
"
SHOW_XAPI_STATEMENTS
"
,
default
=
False
)
# Application definition
...
...
This diff is collapsed.
Click to expand it.
src/static/xapi_statement.schema.json
+
1
−
7
View file @
173bcd82
...
...
@@ -234,13 +234,7 @@
"$ref"
:
"#/$defs/group"
},
"contextActivities"
:
{
"type"
:
"object"
,
"properties"
:
{
"parent"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/$defs/activity"
}
},
"category"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/$defs/activity"
}
},
"grouping"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/$defs/activity"
}
},
"other"
:
{
"type"
:
"array"
,
"items"
:
{
"$ref"
:
"#/$defs/activity"
}
}
}
"type"
:
"object"
},
"revision"
:
{
"type"
:
"string"
...
...
This diff is collapsed.
Click to expand it.
src/xapi/views.py
+
11
−
6
View file @
173bcd82
...
...
@@ -126,7 +126,8 @@ def process_statement(x_api_statement, provider, latest_schema):
# has the user given consent to the object at hand?
object_consent
=
False
verb_objects
=
json
.
loads
(
user_consent
.
object
)
if
not
verb_objects
:
# no objects defined, "consent" by default
object_statement
=
x_api_statement
[
"
object
"
][
"
definition
"
]
if
not
verb_objects
or
len
(
verb_objects
)
==
0
:
# no objects defined, "consent" by default
object_consent
=
True
else
:
for
obj
in
verb_objects
:
...
...
@@ -154,7 +155,7 @@ def process_statement(x_api_statement, provider, latest_schema):
return
{
"
valid
"
:
True
,
"
accepted
"
:
False
,
"
reason
"
:
"
User has not given consent to this object
"
,
"
reason
"
:
f
"
User has not given consent to this object
:
{
object_statement
}
for verb
{
verb
}
"
,
}
return
{
"
valid
"
:
True
,
"
accepted
"
:
True
}
...
...
@@ -241,10 +242,11 @@ class CreateStatement(APIView):
)
# TODO remove this actor override
#
for stmt in x_api_statements:
#
stmt["actor"]["account"]["name"] = "user1@polaris.com"
for
stmt
in
x_api_statements
:
stmt
[
"
actor
"
][
"
account
"
][
"
name
"
]
=
"
user1@polaris.com
"
#print(x_api_statements)
if
settings
.
SHOW_XAPI_STATEMENTS
:
print
(
x_api_statements
)
result
=
[
process_statement
(
stmt
,
provider
,
latest_schema
)
...
...
@@ -254,7 +256,10 @@ class CreateStatement(APIView):
invalid_or_not_consented
=
(
len
([
e
for
e
in
result
if
e
[
"
valid
"
]
==
False
or
e
[
"
accepted
"
]
==
False
])
>
0
)
)
if
settings
.
SHOW_XAPI_STATEMENTS
:
print
(
result
)
if
invalid_or_not_consented
:
return
JsonResponse
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment