Peter Blair

Using python decorators for authentication checks

Consider the following example: A class decodes a JSON string and inspects it for certain authentication tokens. These token can be anything representing an authenticated session, I’m using the simple boolean check for my example.

By using a decorator like the following:

You can use the decorator above any method that handles JSON requests for authentication.


Categorised as: Programming, Python, UNIX


Comments are closed.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes