Default behaviour seems to be new users have no permissions and no groups. However I'd like not to have to manually grant every single new users basic permissions, and I'd assume they'd like not to have to wait for me to do so.
How should I assign default permissions for new users?
Some similar questions have been asked but with no clear answer for the general case:
I'm using python-social-auth
so I don't have my own create-user form and view which I guess is where everyone else sets default permissions. I assume I need an on-user-create hook of some sort but not sure what the cleanest approach is.
This is unrelated to creating the default possible permissions that may be granted to users, although for reference,
New files created in your account are given a default protection of 644 (that is, 666 - 022), which grants read and write permission to the owner of the file, and read permission to the group and others.
These values are additive for each "triplet", meaning that a file permission of rw- has the value of 6 and rwx has the value of 7. As discussed above, any file that's newly created, the default value is 644 (rw-r--r--), meaning that the file's owner can read and write, and all others can only read this file.
To change the default permissions that are set when you create a file or directory within a session or with a script, use the umask command. The syntax is similar to that of chmod (above), but use the = operator to set the default permissions.
Instead, create a Conditional Access policy that targets Microsoft Azure Management will block non-administrators access to Microsoft Azure Management.
You can subscribe to post_save signal on User model and put newly created user to desired group or add permissions.
from django.contrib.auth.models import Group
def add_to_default_group(sender, **kwargs):
user = kwargs["instance"]
if kwargs["created"]:
group = Group.objects.get(name='groupname')
user.groups.add(group)
And on django 1.8+ put following code into your AppConfig.ready()
from django.conf import settings
post_save.connect(add_to_default_group, sender=settings.AUTH_USER_MODEL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With