Code Monkey home page Code Monkey logo

mod_psm's Introduction

Apache2 PSM module

This repository contains a Apache2 module to manage a "Private State". From HTTP1/1 you can manage a state between requests within a specific domain. In HTTP protocol, this mechanism is also called "Cookies"; see RFC6265. So, by setting cookies (Set-Cookie header) you can put and share a state between in your state-less API(s). However anything ensure to your server that the client will not modify the content of these cookies (a.k.a. the state itself).

This "Private State Manager" is a Apache2 module which resolve this issue. On outgoing request, it will replace data within Set-Cookies headers with a token. When PSM detect a token in Cookie header of incoming headers, it will replace it with data previously set.

Let's have a look to the following schema :

alt tag

How-to build ?

Please install autotools and follow the instructions:

./autogen.sh
./configure [--with-apxs=<apxs path>]
make
sudo make install

Basic example

It's not clear ? Ok, assuming a HTTP client and its server. In the following request, the server will set a cookie named "Key" with the value "Value".

> GET /resource HTTP/1.1
> Host: example.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Set-Cookie: Key=Value;
< Content-Length: 12
< Content-Type: text/html; charset=UTF-8
<
Hello world

To ensure that your cookie will not change, PSM will replace your cookie by a token and store the data set by the server. From server point of view, it will look exactly like the previous request. From client point of view, it will looks like :

> GET /resource HTTP/1.1
> Host: example.net
> Accept: */*
>
< HTTP/1.1 200 OK
< Set-Cookie: t=aec8d9a1czyu54qx;
< Content-Length: 12
< Content-Type: text/html; charset=UTF-8
<
Hello world

At the next request your client will send the following request:

> GET /resource HTTP/1.1
> Host: example.net
> Accept: */*
> Cookie: t=aec8d9a1czyu54qx

The token will be replaced by data previously set by your server. It's coming to the server like :

> GET /resource HTTP/1.1
> Host: example.net
> Accept: */*
> Cookie: Key=Value

mod_psm's People

Contributors

rmedaer avatar

Stargazers

 avatar

Watchers

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