Comments (6)
Nice. Is there any way we can generalize this so that it can apply to all the views? If not, is there a way to generalize it for mutating views?
from django-scim2.
Sorry for my terrible english
In PostView
base class we check if inheristance had implemented post_post
, so in gereral not things change.
Below is my code in real project
# scim\views.py
class PostView(object):
def post(self, request, **kwargs):
obj = self.model_cls()
scim_obj = self.scim_adapter(obj, request=request)
body = json.loads(request.body.decode(constants.ENCODING))
scim_obj.from_dict(body)
try:
scim_obj.save(force_insert=True)
if hasattr(self, 'post_post'):
self.post_post(scim_obj, body)
In inheristance View, implement post_post
method
class IdmUserView(UsersView):
""" Override ScimUser view for addtion query parameter
"""
def post_post(self, scim_obj, body):
user = User.objects.get(id=str(scim_obj.obj.id))
UserCredenticalHistory.add(user=user, action="NEWUSER", data=scim_obj.to_dict())
# save to group if request
groupid = body.get("group")
if groupid:
try:
group = get_group_model().objects.get(id=groupid)
group.user_set.add(user)
except Exception as e:
return {"error": str(e)}
return None
scim_adapter = IdmSCIMUserAdapter
model_cls = User
get_extra_filter_kwargs = user_get_extra_model_filter_kwargs_getter(model_cls)
get_extra_exclude_kwargs = empty_get_extra_model_exclude_kwargs_getter(model_cls)
from django-scim2.
Sorry for the delay. Got time now from work to look into this.
The way we do it is we inherit from the django_scim.adapters.SCIMUser
model and override it.
For example,
from django_scim.adapters import SCIMUser
class CustomSCIMUser(SCIMUser):
...
def from_dict(self, d):
...
if self.obj.is_active = d.get('is_active'):
...
def save(self):
...
logger.info('User saved')
Then in your settings file...
SCIM_SERVICE_PROVIDER = {
...
'USER_ADAPTER': 'scim.adapters.CustomSCIMUser',
...
}
from django-scim2.
Would this work for you?
from django-scim2.
work perfect, thanks
from django-scim2.
Great. Thanks for the input @truonghoangnguyen !
from django-scim2.
Related Issues (20)
- Implement get_user_model same as get_group_model HOT 8
- Sorting based on modified field not supported in get_many method HOT 2
- asking for username and password when accessing v2/scim/Users HOT 1
- Unable to Decouple the User Model HOT 4
- Use the django ORM for filters instead of a custom SQL query generator
- Incompatibility with django 4 HOT 2
- Not syncing the group members HOT 5
- userName attribute should be case-insensitive, per the RFC HOT 6
- Unauthorized issues HOT 4
- Support SCIM views with custom authentication mechanisms HOT 4
- Move to Pytest
- Re-creating of users HOT 2
- admin's scim_id was changed. HOT 4
- Support SCIM 1.1 Implementations HOT 1
- Extend custom authentication mechanisms to authenticate by request. HOT 2
- Why is `get_queryset_post_processor` not applied to querysets in `_search`? HOT 1
- GitHub Sponsor HOT 8
- ModuleNotFoundError: No module named 'django_scim' HOT 2
- Decouple User model from SCIM attributes? HOT 3
- Filters don't apply to reverse foreign keys.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-scim2.