All Projects → ourway → auth

ourway / auth

Licence: MIT license
Authorization for humans

Programming Languages

python
139335 projects - #7 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to auth

Kan
Simple, functional authorization library and role management for ruby
Stars: ✭ 232 (+373.47%)
Mutual labels:  roles, authorization
Php Casbin
An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .
Stars: ✭ 865 (+1665.31%)
Mutual labels:  roles, authorization
keycloak-restrict-client-auth
A Keycloak authenticator to restrict authorization on clients
Stars: ✭ 34 (-30.61%)
Mutual labels:  roles, authorization
Laratrust
Handle roles and permissions in your Laravel application
Stars: ✭ 1,799 (+3571.43%)
Mutual labels:  roles, authorization
Security.identity
.NET DevPack Identity is a set of common implementations to help you implementing Identity, Jwt, claims validation and another facilities
Stars: ✭ 165 (+236.73%)
Mutual labels:  roles, authorization
HeimGuard
🛡 A simple library that allows you to easily manage permissions in your .NET projects.
Stars: ✭ 77 (+57.14%)
Mutual labels:  roles, authorization
Laravel Auth
A powerful authentication, authorization and verification package built on top of Laravel. It provides developers with Role Based Access Control, Two-Factor Authentication, Social Authentication, and much more, compatible Laravel’s standard API and fully featured out of the box.
Stars: ✭ 128 (+161.22%)
Mutual labels:  roles, authorization
laravel-roles-abilities-tutorial
Tutorial demonstrating the implementation of roles and abilities in Laravel
Stars: ✭ 16 (-67.35%)
Mutual labels:  roles, authorization
Sentinel
A framework agnostic authentication & authorization system.
Stars: ✭ 1,354 (+2663.27%)
Mutual labels:  roles, authorization
Brandenburg
Laravel Authentication Package
Stars: ✭ 79 (+61.22%)
Mutual labels:  roles, authorization
Vue Router User Roles
A Vue.js plugin that protects routes based on user roles. Add your own authentication.
Stars: ✭ 237 (+383.67%)
Mutual labels:  roles, authorization
Think Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in ThinkPHP 6.0 .
Stars: ✭ 155 (+216.33%)
Mutual labels:  roles, authorization
firebase-spring-boot-rest-api-authentication
Firebase Spring Boot Rest API Authentication
Stars: ✭ 172 (+251.02%)
Mutual labels:  roles, authorization
Laravel Governor
Manage authorization with granular role-based permissions in your Laravel Apps.
Stars: ✭ 131 (+167.35%)
Mutual labels:  roles, authorization
nova-permissions
Add Permissions based authorization for your Nova installation via User-based Roles and Permissions. Roles are defined in the database whereas Permissions are defined in the code base.
Stars: ✭ 115 (+134.69%)
Mutual labels:  roles, authorization
Policyserver.local
Sample OSS version of PolicyServer
Stars: ✭ 444 (+806.12%)
Mutual labels:  roles, authorization
Monarchy
Hierarchical access management system with advanced roles inheritance. 🦋
Stars: ✭ 48 (-2.04%)
Mutual labels:  roles, authorization
Accesscontrol
Role and Attribute based Access Control for Node.js
Stars: ✭ 1,723 (+3416.33%)
Mutual labels:  roles, authorization
Bouncer
Eloquent roles and abilities.
Stars: ✭ 2,763 (+5538.78%)
Mutual labels:  roles, authorization
Think Casbin
专为ThinkPHP定制的Casbin的扩展包,Casbin是一个功能强大,高效的开源访问控制库。
Stars: ✭ 138 (+181.63%)
Mutual labels:  roles

Auth | Authorization for Humans

RESTful, Simple Authorization system with ZERO configuration.

https://codecov.io/github/ourway/auth/coverage.svg?branch=master

What is Auth?

Auth is a module that makes authorization simple and also scalable and powerful. It also has a beautiful RESTful API for use in micro-service architectures and platforms. It is originally desinged to use in Appido, a scalable media market in Iran.

It supports Python2.6+ and if you have a mongodb backbone, you need ZERO configurations steps. Just type auth-server and press enter!

I use Travis and Codecov to keep myself honest.

requirements

You need to access to mongodb. If you are using a remote mongodb, provide these environment variables:

MONGO_HOST and MONGO_PORT

Installation

pip install auth

Show me an example

ok, lets image you have two users, Jack and Sara. Sara can cook and Jack can dance. Both can laugh.

You also need to choose a secret key for your application. Because you may want to use Auth in various tools and each must have a secret key for seperating their scope.

my_secret_key = "pleaSeDoN0tKillMyC_at"
from auth import Authorization
cas = Authorization(my_secret_key)

Now, Lets add 3 groups, Cookers, Dancers and Laughers. Remember that groups are Roles. So when we create a group, indeed we create a role:

cas.add_group('cookers')
cas.add_group('dancers')
cas.add_group('laughers')

Ok, great. You have 3 groups and you need to authorize them to do special things.

cas.add_permission('cookers', 'cook')
cas.add_permission('dancers', 'dance')
cas.add_permission('laughers', 'laugh')

Good. You let cookers to cook and dancers to dance etc... The final part is to set memberships for Sara and Jack:

cas.add_membership('sara', 'cookers')
cas.add_membership('sara', 'laughers')
cas.add_membership('jack', 'dancers')
cas.add_membership('jack', 'laughers')

That's all we need. Now lets ensure that jack can dance:

if cas.user_has_permission('jack', 'dance'):
    print('YES!!! Jack can dance.')

Authorization Methods

use pydoc to see all methods:

pydoc auth.Authorization

RESTful API

Lets run the server on port 4000:

from auth import api, serve
serve('localhost', 4000, api)

Or, from version 0.1.2+ you can use this command:

auth-server

Simple! Authorization server is ready to use.

https://raw.githubusercontent.com/ourway/auth/master/docs/API_Usage_Teminal.gif

You can use it via simple curl or using mighty Requests module. So in you remote application, you can do something like this:

import requests
secret_key = "pleaSeDoN0tKillMyC_at"
auth_api = "http://127.0.0.1:4000/api"

Lets create admin group:

requests.post(auth_api+'/role/'+secret_key+'/admin')

And lets make Jack an admin:

requests.post(auth_api+'/permission/'+secret_key+'/jack/admin')

And finally let's check if Sara still can cook:

requests.get(auth_api+'/has_permission/'+secret_key+'/sara/cook')

RESTful API helpers

auth comes with a helper class that makes your life easy.

from auth.client import Client
service = Client('srv201', 'http://192.168.99.100:4000')
print(service)
service.get_roles()
service.add_role(role='admin')

API Methods

pydoc auth.CAS.REST.service
  • /ping [GET]
Ping API, useful for your monitoring tools
  • /api/membership/{KEY}/{user}/{role} [GET/POST/DELETE]
Adding, removing and getting membership information.
  • /api/permission/{KEY}/{role}/{name} [GET/POST/DELETE]
Adding, removing and getting permissions
  • /api/has_permission/{KEY}/{user}/{name} [GET]
Getting user permission info
  • /api/role/{KEY}/{role} [GET/POST/DELETE]

    Adding, removing and getting roles

  • /api/which_roles_can/{KEY}/{name} [GET]

    For example: Which roles can send_mail?

  • /api/which_users_can/{KEY}/{name} [GET]

    For example: Which users can send_mail?

  • /api/user_permissions/{KEY}/{user} [GET]

    Get all permissions that a user has

  • /api/role_permissions/{KEY}/{role} [GET]

    Get all permissions that a role has

  • /api/user_roles/{KEY}/{user} [GET]

    Get roles that user assinged to

  • /api/roles/{KEY} [GET]

    Get all available roles

Deployment

Deploying Auth module in production environment is easy:

gunicorn auth:api

Dockerizing

It's simple:

docker build -t python/auth-server https://raw.githubusercontent.com/ourway/auth/master/Dockerfile
docker run --name=auth -e MONGO_HOST='192.168.99.100' -p 4000:4000 -d --restart=always --link=mongodb-server python/auth-server

Copyright

  • Farsheed Ashouri @

Documentation

Feel free to dig into source code. If you think you can improve the documentation, please do so and send me a pull request.

Unit Tests and Coverage

I am trying to add tests as much as I can, but still there are areas that need improvement.

To DO

  • Add Authentication features
  • Improve Code Coverage
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].