Giter Club home page Giter Club logo

access_control's Introduction

rbac

Role Based Access Control System

Overview

Basic role based access control (authorization) system.

Functional requirements

  1. Given a user, action type and resource system should be able to tell whether the user has access or not.
  2. System should be able to assign a role to user and remove a user from the role.

Behavioral requirements

  1. Access to resources for users are controlled strictly by the role.
  2. One user can have multiple roles.

Design

Design is kept simple, modular and extensible.

Modules

Alt text

There are three modules:

  1. Command line interface: The module responsible for interaction with the end-user. Currently it is basic command line interface, but later it can be changed/replaced without affecting other modules. For example: it can be replaced by REST API.
  2. Authorization System: This module contains the logic to determine if the user is authorized for certain action on the resource.
  3. Data Access Object: This module is responsible for interacting with the storage and provide the data to the application. Currently it reads from csv file, and keeps the data in memory. It can easily be replaced with another DAO which interacts with Database.

Data

Data is represented as Entities and relationships.

Alt text

Entities

  1. User: All the information about the user.
  2. Role: All the information about the role.
  3. Resource: All the information about the resource.

Relationships

  1. User Role Relation: The Many-to-many relationship between users and roles.
  2. Role Resource Relation: The Many-to-Many relationship between roles and resources.

Implementation

Implementation is done in python3.6. No external library is used.

####Files

user_iterface.py

This file represents Command line interface module. It interacts directly with authorization module, but not with data access module. The function start contains the loop to receive and execute the command.

authorization.py

This file represents Authorization system module. It interacts directly with data access module. It provides functions: is_authorized, add_role_to_user and remove_user_from_role.

data_access_object.py

This file represents Data Access Object module. It interacts with storage(csv files) to provide data access to other modules.

models.py

This file contains the definition of entities and relationships.

main.py

This file stitch together all the module into an application.

exceptions.py

This file contains definition of commonly occurring exceptions.

Usage/Execution

The system can be started using command

python main.py

The program load the data from data directory and provides a command prompt for basic functionality.

Commands

  1. help: To know about available commands.
  2. users: To see all users.
  3. roles: To see all roles.
  4. resources: To see all resources.
  5. assign <user_id> <role_id>: To assign a user to a role.
  6. remove <user_id> <role_id>: To remove a user from a role. exit: To exit from command prompt.

access_control's People

Contributors

diveshkapoor avatar

Watchers

 avatar

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.