Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
it-bott-integrasjoner
greg
Commits
8c380853
Commit
8c380853
authored
3 years ago
by
Sivert Kronen Hatteberg
Browse files
Options
Downloads
Patches
Plain Diff
Fix oidc auth, remove email from person object
parent
7faf5f73
No related branches found
No related tags found
No related merge requests found
Pipeline
#96847
canceled
3 years ago
Stage: venv update
Stage: tests and linting
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gregui/authentication/auth_backends.py
+11
-1
11 additions, 1 deletion
gregui/authentication/auth_backends.py
gregui/tests/conftest.py
+2
-3
2 additions, 3 deletions
gregui/tests/conftest.py
gregui/tests/test_oidc.py
+1
-1
1 addition, 1 deletion
gregui/tests/test_oidc.py
with
14 additions
and
5 deletions
gregui/authentication/auth_backends.py
+
11
−
1
View file @
8c380853
...
@@ -205,7 +205,6 @@ class GregOIDCBackend(ValidatingOIDCBackend):
...
@@ -205,7 +205,6 @@ class GregOIDCBackend(ValidatingOIDCBackend):
person
,
_
=
Person
.
objects
.
update_or_create
(
person
,
_
=
Person
.
objects
.
update_or_create
(
first_name
=
userinfo
[
"
first_name
"
],
first_name
=
userinfo
[
"
first_name
"
],
last_name
=
userinfo
[
"
last_name
"
],
last_name
=
userinfo
[
"
last_name
"
],
email
=
userinfo
[
"
email
"
],
)
)
person
.
save
()
person
.
save
()
return
person
return
person
...
@@ -242,6 +241,17 @@ class GregOIDCBackend(ValidatingOIDCBackend):
...
@@ -242,6 +241,17 @@ class GregOIDCBackend(ValidatingOIDCBackend):
)
)
identity
.
save
()
identity
.
save
()
try
:
email_identity
=
Identity
.
objects
.
get
(
type
=
"
private_email
"
,
value
=
userinfo
[
"
email
"
]
)
except
Identity
.
DoesNotExist
:
# Add email if missing
email_identity
=
Identity
(
type
=
"
private_email
"
,
value
=
userinfo
[
"
email
"
],
person
=
person
)
email_identity
.
save
()
user_profile
=
GregUserProfile
(
user_profile
=
GregUserProfile
(
user
=
user
,
user
=
user
,
person
=
person
,
person
=
person
,
...
...
This diff is collapsed.
Click to expand it.
gregui/tests/conftest.py
+
2
−
3
View file @
8c380853
...
@@ -76,14 +76,13 @@ def data():
...
@@ -76,14 +76,13 @@ def data():
"
person1
"
:
{
"
person1
"
:
{
"
type
"
:
"
feide_id
"
,
"
type
"
:
"
feide_id
"
,
"
value
"
:
"
foo@example.com
"
,
"
value
"
:
"
foo@example.com
"
,
"
person
"
:
{
"
email
"
:
"
foo@example.com
"
},
"
person
"
:
{
"
last_name
"
:
"
Baresen
"
},
},
},
},
},
"
Person
"
:
{
"
Person
"
:
{
"
person1
"
:
{
"
person1
"
:
{
"
first_name
"
:
"
Foo
"
,
"
first_name
"
:
"
Foo
"
,
"
last_name
"
:
"
Baresen
"
,
"
last_name
"
:
"
Baresen
"
,
"
email
"
:
"
foo@example.com
"
,
},
},
},
},
"
Sponsor
"
:
{
"
Sponsor
"
:
{
...
@@ -231,6 +230,7 @@ def invitation_link_expired(invitation, invitation_expired_date) -> InvitationLi
...
@@ -231,6 +230,7 @@ def invitation_link_expired(invitation, invitation_expired_date) -> InvitationLi
return
InvitationLink
.
objects
.
get
(
id
=
il
.
id
)
return
InvitationLink
.
objects
.
get
(
id
=
il
.
id
)
@pytest.fixture
def
greg_users
(
data
):
def
greg_users
(
data
):
return
create_objects
(
get_user_model
(),
data
[
"
User
"
])
return
create_objects
(
get_user_model
(),
data
[
"
User
"
])
...
@@ -257,4 +257,3 @@ def log_in(client, greg_users):
...
@@ -257,4 +257,3 @@ def log_in(client, greg_users):
return
client
return
client
return
_log_in
return
_log_in
This diff is collapsed.
Click to expand it.
gregui/tests/test_oidc.py
+
1
−
1
View file @
8c380853
...
@@ -60,7 +60,7 @@ def test_create_user(claims):
...
@@ -60,7 +60,7 @@ def test_create_user(claims):
person
=
userProfile
.
person
person
=
userProfile
.
person
assert
person
.
first_name
==
user
.
first_name
assert
person
.
first_name
==
user
.
first_name
assert
person
.
last_name
==
user
.
last_name
assert
person
.
last_name
==
user
.
last_name
assert
person
.
email
==
user
.
email
assert
person
.
identities
.
filter
(
type
=
"
private_email
"
).
first
().
value
==
user
.
email
ids
=
Identity
.
objects
.
get
(
person
=
person
,
type
=
"
feide_id
"
)
ids
=
Identity
.
objects
.
get
(
person
=
person
,
type
=
"
feide_id
"
)
assert
ids
.
value
==
"
frank_foreleser@spusers.feide.no
"
assert
ids
.
value
==
"
frank_foreleser@spusers.feide.no
"
...
...
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