Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp-account
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp-account
Commits
be692534
Commit
be692534
authored
6 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
update: retro compatibility
parent
31576de8
No related branches found
No related tags found
1 merge request
!8
Resolve "Login endpoint"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp_account/endpoints/rp_login.py
+11
-5
11 additions, 5 deletions
djangoldp_account/endpoints/rp_login.py
djangoldp_account/urls.py
+5
-4
5 additions, 4 deletions
djangoldp_account/urls.py
with
16 additions
and
9 deletions
djangoldp_account/endpoints/rp_login.py
+
11
−
5
View file @
be692534
from
urllib.parse
import
urlparse
import
validators
from
django.conf
import
settings
from
django.contrib.auth
import
login
,
get_user_model
...
...
@@ -157,7 +159,7 @@ class RPLoginCallBackEndpoint(object):
def
extract_web_id
(
self
,
userinfo
):
"""
@
See https://github.com/solid/webid-oidc-spec/blob/master/README.md#method-1---custom-webid-claim
See https://github.com/solid/webid-oidc-spec/blob/master/README.md#method-1---custom-webid-claim
:param userinfo:
:return:
"""
...
...
@@ -172,11 +174,13 @@ class RPLoginCallBackEndpoint(object):
def
confirm_webid
(
self
,
webid
):
"""
@s
ee https://github.com/solid/webid-oidc-spec/blob/master/README.md#webid-provider-confirmation
S
ee https://github.com/solid/webid-oidc-spec/blob/master/README.md#webid-provider-confirmation
:param webid:
:return:
"""
if
webid
.
startswith
(
self
.
client
.
issuer
):
url
=
urlparse
(
self
.
client
.
issuer
)
webid_url
=
urlparse
(
webid
)
if
webid_url
.
netloc
==
url
.
netloc
:
pass
else
:
raise
LDPLoginError
(
'
cannot_confirm_webid
'
)
...
...
@@ -190,6 +194,8 @@ class RPLoginCallBackEndpoint(object):
if
existing_user
is
not
None
:
user
=
existing_user
else
:
user
=
get_user_model
().
objects
.
create_user
(
username
=
webid
,
first_name
=
userinfo
[
'
given_name
'
],
last_name
=
userinfo
[
'
family_name
'
],
email
=
userinfo
[
'
email
'
])
user
=
get_user_model
().
objects
.
create_user
(
username
=
webid
,
first_name
=
userinfo
[
'
given_name
'
],
last_name
=
userinfo
[
'
family_name
'
],
email
=
userinfo
[
'
email
'
])
login
(
self
.
request
,
user
,
backend
=
'
django.contrib.auth.backends.ModelBackend
'
)
This diff is collapsed.
Click to expand it.
djangoldp_account/urls.py
+
5
−
4
View file @
be692534
...
...
@@ -5,6 +5,8 @@ from django.conf import settings
from
django.conf.urls
import
url
,
include
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth.models
import
Group
from
django.urls
import
reverse_lazy
from
django.views.generic
import
RedirectView
from
djangoldp.permissions
import
AnonymousReadOnly
from
djangoldp.views
import
LDPViewSet
...
...
@@ -30,13 +32,12 @@ urlpatterns = [
nested_fields
=
user_nested_fields
)),
url
(
r
'
^accounts/
'
,
include
(
'
django.contrib.auth.urls
'
)),
url
(
r
'
^accounts/
'
,
LDPViewSet
.
urls
(
model
=
Account
,
permission_classes
=
[
AnonymousReadOnly
])),
url
(
r
'
^chat-profile/
'
,
LDPViewSet
.
urls
(
model
=
ChatProfile
,
permission_classes
=
[
AnonymousReadOnly
])),
url
(
r
'
^chat-profile/
?
'
,
LDPViewSet
.
urls
(
model
=
ChatProfile
,
permission_classes
=
[
AnonymousReadOnly
])),
url
(
r
'
^ldp/login/callback/?$
'
,
RPLoginCallBackView
.
as_view
(),
name
=
'
ldp_login_callback
'
),
url
(
r
'
^ldp/login/?$
'
,
RPLoginView
.
as_view
(),
name
=
'
ldp_login
'
),
url
(
r
'
^userinfo/?$
'
,
userinfocustom
),
url
(
r
'
^
'
,
include
(
'
oidc_provider.urls
'
,
namespace
=
'
oidc_provider
'
))
,
url
(
r
'
^
openid/
userinfo/?$
'
,
userinfocustom
),
url
(
r
'
^
openid/
'
,
include
(
'
oidc_provider.urls
'
,
namespace
=
'
oidc_provider
'
))
]
s_fields
=
[]
s_fields
.
extend
(
user_fields
)
s_fields
.
extend
(
user_nested_fields
)
...
...
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