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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Polaris
Rights Engine
Commits
d8eff660
Commit
d8eff660
authored
1 year ago
by
Benjamin Ledel
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
ssh://gitlab.digitallearning.gmbh:2222/polaris/rights-engine
parents
ec294c83
dfc50ba5
No related branches found
No related tags found
No related merge requests found
Pipeline
#1275799
failed
1 year ago
Stage: test
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/consents/serializers.py
+4
-1
4 additions, 1 deletion
src/consents/serializers.py
src/consents/urls.py
+1
-0
1 addition, 0 deletions
src/consents/urls.py
src/consents/views.py
+38
-3
38 additions, 3 deletions
src/consents/views.py
with
43 additions
and
4 deletions
src/consents/serializers.py
+
4
−
1
View file @
d8eff660
...
...
@@ -93,3 +93,6 @@ class CreateUserSerializer(serializers.Serializer):
email
=
serializers
.
CharField
()
first_name
=
serializers
.
CharField
()
last_name
=
serializers
.
CharField
()
class
CreateUserShibbolethSerializer
(
serializers
.
Serializer
):
email
=
serializers
.
CharField
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/consents/urls.py
+
1
−
0
View file @
d8eff660
...
...
@@ -8,6 +8,7 @@ urlpatterns = [
path
(
'
provider/create
'
,
views
.
CreateProviderConsentView
.
as_view
()),
path
(
'
user/save
'
,
views
.
SaveUserConsentView
.
as_view
()),
path
(
'
user/create
'
,
views
.
CreateUserConsentView
.
as_view
()),
path
(
'
user/create-via-shibboleth
'
,
views
.
CreateUserConsentViaShibbolethView
.
as_view
()),
path
(
'
user/status
'
,
views
.
GetUserConsentStatusView
.
as_view
()),
path
(
'
user/analytics-tokens
'
,
views
.
GetUserConsentAnalyticsTokens
.
as_view
()),
path
(
'
user/analytics-tokens/consent
'
,
views
.
SaveUserConsentAnalyticsTokens
.
as_view
()),
...
...
This diff is collapsed.
Click to expand it.
src/consents/views.py
+
38
−
3
View file @
d8eff660
import
json
import
string
import
random
import
os
import
secrets
...
...
@@ -15,12 +17,12 @@ from rest_framework.views import APIView
from
backend.role_permission
import
IsProvider
from
consents.serializers
import
(
ProviderSchemaSerializer
,
ProvidersSerializer
,
SaveUserConsentSerializer
,
CreateUserSerializer
)
SaveUserConsentSerializer
,
CreateUserSerializer
,
CreateUserShibbolethSerializer
)
from
providers.models
import
AnalyticsToken
,
AnalyticsTokenVerb
,
Provider
,
ProviderAuthorization
,
ProviderSchema
from
providers.serializers
import
(
AnalyticsTokenSerializer
,
ConsentUserVerbThirdPartySerializer
,
GetUsersConsentsThirdPartySerializer
)
from
users.models
import
CustomUser
from
xapi.views
import
shib_connector_resolver
from
xapi.views
import
shib_connector_resolver
,
shib_connector_resolver_to_pairwaise_id
from
.models
import
UserConsents
...
...
@@ -352,7 +354,6 @@ class CreateUserConsentView(APIView):
serializer
.
is_valid
(
raise_exception
=
True
)
email
=
serializer
.
validated_data
[
"
email
"
]
email
=
shib_connector_resolver
(
email
=
email
,
provider
=
provider
)
if
CustomUser
.
objects
.
filter
(
email
=
email
).
first
()
is
None
:
user
=
CustomUser
.
objects
.
create
(
...
...
@@ -369,6 +370,40 @@ class CreateUserConsentView(APIView):
status
=
status
.
HTTP_200_OK
,
)
class
CreateUserConsentViaShibbolethView
(
APIView
):
def
post
(
self
,
request
):
application_token
=
request
.
headers
.
get
(
"
Authorization
"
,
""
).
split
(
"
Basic
"
)[
-
1
]
provider
=
ProviderAuthorization
.
objects
.
filter
(
key
=
application_token
).
first
()
if
provider
is
None
:
return
JsonResponse
(
{
"
message
"
:
"
invalid access token
"
},
safe
=
False
,
status
=
status
.
HTTP_401_UNAUTHORIZED
,
)
serializer
=
CreateUserShibbolethSerializer
(
data
=
request
.
data
,
many
=
True
)
serializer
.
is_valid
(
raise_exception
=
True
)
email
=
serializer
.
validated_data
[
"
email
"
]
shib_id
=
shib_connector_resolver_to_pairwaise_id
(
email
=
email
,
provider
=
provider
)
if
CustomUser
.
objects
.
filter
(
uid
=
shib_id
).
first
()
is
None
:
user
=
CustomUser
.
objects
.
create
(
uid
=
shib_id
,
# this is the pairwaise id
email
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
digits
,
k
=
8
))
+
"
@manual-created.polaris
"
,
first_name
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
digits
,
k
=
8
)),
last_name
=
''
.
join
(
random
.
choices
(
string
.
ascii_uppercase
+
string
.
digits
,
k
=
8
))
)
return
JsonResponse
(
{
"
user
"
:
user
,
},
safe
=
False
,
status
=
status
.
HTTP_200_OK
,
)
class
SaveUserConsentView
(
APIView
):
"""
Saves a user consent.
...
...
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