Giter Club home page Giter Club logo

Comments (5)

logston avatar logston commented on August 22, 2024

Hmm, did you set USER_ADAPTER:

https://github.com/15five/django-scim2/blob/master/src/django_scim/settings.py#L8-L11

from django-scim2.

Katert avatar Katert commented on August 22, 2024

Hmm, did you set USER_ADAPTER:

https://github.com/15five/django-scim2/blob/master/src/django_scim/settings.py#L8-L11

I've used the default values from your adapters.py file:

SCIM_SERVICE_PROVIDER = {
'USER_ADAPTER': 'django_scim.adapters.SCIMUser',
'GROUP_ADAPTER': 'django_scim.adapters.SCIMGroup',
'SERVICE_PROVIDER_CONFIG_MODEL': 'django_scim.models.SCIMServiceProviderConfig',
'NETLOC': 'localhost',
'AUTHENTICATION_SCHEMES': [
{
'type': 'oauth2',
'name': 'OAuth 2',
'description': 'Oauth 2 implemented with bearer token',
'specUri': '',
'documentationUri': '',
'primary': 'true'
},
{
"name": "HTTP Basic",
"description": "Authentication scheme using the HTTP Basic Standard",
"type": "httpbasic"
}
],
'WWW_AUTHENTICATE_HEADER': 'Bearer realm="api"',
}

My user model inherits from AbstractSCIMUserMixin and AbstractUser:

` class User(AbstractUser, AbstractSCIMUserMixin):

email = EmailField(unique=True)

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []

def __str__(self):
    return self.email `

I have noticed that AbstractSCIMUserMixin has the following property:

@property def scim_groups(self): raise exceptions.NotImplementedError

I'm sure that's why I keep receiving a 501 - Not Implemented status, but I'm not sure how to interpret this.

from django-scim2.

Katert avatar Katert commented on August 22, 2024

This can be closed. I solved this by implementing a custom Group which inherits from AbstractSCIMGroupMixin and django.contrib.auth.models.Group. I've declared a ManyToManyField to this custom group called "groups" in my custom User model. After that I override the scim_groups property in my custom User model and set it to return self.groups:

`
class Group(Group, AbstractSCIMGroupMixin):

def __str__(self):
    return self.scim_display_name

class User(AbstractUser, AbstractSCIMUserMixin):

email = EmailField(unique=True)
scim_username = models.CharField(
    _('SCIM Username'),
    max_length=254,
    null=True,
    blank=True,
    default=None,
    unique=True,
    db_index=True,
    help_text=_("A service provider's unique identifier for the user"),
)
groups = models.ManyToManyField(Group)

@property
def scim_groups(self):
    return self.groups

USERNAME_FIELD = 'scim_username'

def __str__(self):
    return self.email

`

I'm receiving the correct responses now.

from django-scim2.

Katert avatar Katert commented on August 22, 2024

Hi Paul,

I wanted to ask if the way I solved this is okay.
There are 2 Group-tables in my DB now, one of which has the SCIM-fields with a pointer ID to the corresponding auth.Group model.
It all seems to be working like I would expect, but wanted to ask your view on this.

Thanks in advance.

from django-scim2.

logston avatar logston commented on August 22, 2024

Hey @Katert, that certainly is an option. We've seen a number of ways of integrating this library with the existing code bases. The setup you've mentioned might even be better for you down the road given its decoupled nature.

from django-scim2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.