Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate django authentication system #16

Merged
merged 5 commits into from
Aug 17, 2023
Merged

feat: integrate django authentication system #16

merged 5 commits into from
Aug 17, 2023

Conversation

BustDot
Copy link
Contributor

@BustDot BustDot commented Aug 16, 2023

Add a backend to integrate django authentication system.

@casbin-bot
Copy link

@Nekotoxin please review

@CLAassistant
Copy link

CLAassistant commented Aug 16, 2023

CLA assistant check
All committers have signed the CLA.

@hsluoyz
Copy link
Member

hsluoyz commented Aug 16, 2023

@leeqvip plz review

@hsluoyz hsluoyz merged commit 34770ec into pycasbin:master Aug 17, 2023
15 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 17, 2023
# [1.1.0](v1.0.3...v1.1.0) (2023-08-17)

### Features

* integrate django authentication system ([#16](#16)) ([34770ec](34770ec))
@github-actions
Copy link

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

]
```

注意,由于django权限系统的机制,您仍需要使用pycasbin的`add_policy()`方法来添加策略。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add, modify, and delete permissions ?

myuser.groups.set([group_list])
myuser.groups.add(group, group, ...)
myuser.groups.remove(group, group, ...)
myuser.groups.clear()
myuser.user_permissions.set([permission_list])
myuser.user_permissions.add(permission, permission, ...)
myuser.user_permissions.remove(permission, permission, ...)
myuser.user_permissions.clear()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The django user_permissions module uses its own model, so it can't to do these operations with pycasbin.

else:
if user.check_password(password) and self.user_can_authenticate(user):
return user

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can user authentication be skipped? Hand it over to other Backends to complete.
Only the authorization of permissions is provided here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django will use each backend in order, if users want to custom their own authentication function, they can define a new backend and place it before casbin_backend.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's redundant and useless. Casbin only provides authorization but not authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I will file a new pr to remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants