Giter Club home page Giter Club logo

pysessions's Introduction

pySessions

Pulggable middleware written on python to manage web sessions by using tokens

This simple code block can be pulgged at any where in your exsisting / new projects. This can handle your users active session details with ease.

The most generic part of the session handling is globalized in this package

HOW TO USE

IMPORT AND INITIALIZE

create an instance of authenticator in your project start

from pySessions.authenticator import Authenticator
authenticator  =  Authenticator(unique_key=<uniquekey>,timeout=10000)

The unique may be any like your app name or some random key.

METHODS

To create a session

authenticator.manage(<key>)

The key can be userid or any unique value

it returns

{
"session_id": "b48cb6a2f8648741a71b4f27a670cbaa",
 "status": "success",
 "timeout": 1588381679
}

timeout -> genrated time + default timeout given at obj intialization

To validate a session


authenticator.validate(<session_id>)

The key can be userid or any unique value

it returns


{

 "status": "success",

 "valid": true

}

valid -> contains the session is valid (true) or not valid (false)

List of active sessions

authenticator.active_sessions(<id>)

id -> key used to create sessions

it returns

"active_sessions": [
    {
      "session_id": "9ab74f78ba1cb80b3b97e719ab5ea618",
      "time_ms": 1588382179,
      "user": <userid>
    },
    {
      "session_id": "6a6a65f09710e8853cfcf49b668edb78",
      "time_ms": 1588382180,
      "user": <userid>
    }
  ],
  "status": "success",
  "user_id": <userid>

To destory/blacklist/block sessions

authenticator.block(<session_id>)

This removes that session from the memory

this returns

 {
 "status": "success",
 "deleted":true
 "session_id":<session_id>
 }

The status in all api responses determines the succesfull excecution of the commands

pysessions's People

Stargazers

Someskumar Kumarasamy avatar

Watchers

James Cloos avatar Someskumar Kumarasamy 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.