Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Djangoldp Account
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
djangoldp-packages
Djangoldp Account
Commits
bdd288f8
Commit
bdd288f8
authored
Jul 10, 2019
by
Jean-Baptiste
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: Add a way to customize User and Group permissions classes
parent
83f3e734
Pipeline
#4505
passed with stage
in 27 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
README.md
README.md
+11
-2
djangoldp_account/djangoldp_urls.py
djangoldp_account/djangoldp_urls.py
+5
-4
No files found.
README.md
View file @
bdd288f8
...
...
@@ -81,6 +81,15 @@ Because `/user/1` is an account of an external user with webid `https://theother
djangoldp_account use
`django.contribs.auth.User`
and mange its serialization into JsonLd format
If you need to extends it with you own relation use
`USER_NESTED_FIELDS`
on settings.py :
```
`
```
USER_NESTED_FIELDS=['skills']
```
\ No newline at end of file
```
Also, if you need to override the default permission (AnonymousReadOnly) on User or Group use :
```
GROUP_PERMISSION_CLASSES=[CustomGroupPermission]
USER_PERMISSION_CLASSES=[CustomUserPermission]
```
On the server settings (should be override only one time)
djangoldp_account/djangoldp_urls.py
View file @
bdd288f8
...
...
@@ -17,16 +17,17 @@ user_fields = ['@id', 'first_name', 'groups', 'last_name', 'username', 'email',
user_nested_fields
=
[
'account'
,
'groups'
,
'chatProfile'
]
for
dldp_module
in
djangoldp_modules
:
try
:
user_fields
+=
import_module
(
dldp_module
+
'.settings'
)
.
USER_NESTED_FIELDS
user_nested_fields
+=
import_module
(
dldp_module
+
'.settings'
)
.
USER_NESTED_FIELDS
module_user_nested_fields
=
import_module
(
dldp_module
+
'.settings'
)
.
USER_NESTED_FIELDS
user_fields
+=
module_user_nested_fields
user_nested_fields
+=
module_user_nested_fields
except
:
pass
urlpatterns
=
[
url
(
r'^groups/'
,
LDPViewSet
.
urls
(
model
=
Group
,
fields
=
[
'@id'
,
'name'
,
'user_set'
],
permission_classes
=
[
AnonymousReadOnly
]
)),
LDPViewSet
.
urls
(
model
=
Group
,
fields
=
[
'@id'
,
'name'
,
'user_set'
],
permission_classes
=
getattr
(
settings
,
'GROUP_PERMISSION_CLASSES'
,
[
AnonymousReadOnly
])
)),
url
(
r'^users/'
,
LDPViewSet
.
urls
(
model
=
settings
.
AUTH_USER_MODEL
,
fields
=
user_fields
,
permission_classes
=
[
AnonymousReadOnly
]
,
LDPViewSet
.
urls
(
model
=
settings
.
AUTH_USER_MODEL
,
fields
=
user_fields
,
permission_classes
=
getattr
(
settings
,
'USER_PERMISSION_CLASSES'
,
[
AnonymousReadOnly
])
,
nested_fields
=
user_nested_fields
)),
url
(
r'^accounts/'
,
include
(
'django.contrib.auth.urls'
)),
url
(
r'^accounts/'
,
LDPViewSet
.
urls
(
model
=
Account
,
permission_classes
=
[
AnonymousReadOnly
])),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment