The session-token Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The session-token Reference Manual

This is the session-token Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:34:03 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Session Token

A simple CPRNG-powered session token generator

This implementation cribs heavily from Doug Hoyte's Perl-implemented Session::Token, and it uses his Common Lisp ISAAC implementation (packaged here and here; the first of these is available via quicklisp).

Quick Start

CL-USER> (ql:quickload :session-token)
To load "session-token":
  Load 1 ASDF system:
    session-token
; Loading "session-token"

(:SESSION-TOKEN)
CL-USER> (defvar generator (session-token:make-generator))
GENERATOR
CL-USER> (funcall generator)
"VFZhF1FcxjEXfNl3DQ9NbxtFwDzrRZNc"
CL-USER> (loop repeat 10 collect (funcall generator))
("cwQKz6ADlDebXyEJCv7QdjZPPXOAPaqL" "hW0rRq08vWGfTtm0qAHcqfjewgqnqjF2"
 "PTeUDzzjMBE68zQQEyr1tYfJ06MbMtIW" "KCAbUIOqOaOFaxOqr2T8L6ACH9Te0Ycz"
 "C5todVcryAmpHzM5SZc0L4gboN3QKnEj" "jXKG9kzA4ECOV9FmLGGNh2fLXHxQzjtC"
 "gO4FzN3jXKZxMBX4BfcudTk5iAWwe3F5" "cIach4uqDiX0VhG5MI4NmEZ7JZmBOTyl"
 "K3LfxgOjQIK3Tk0zJJzCOUzjOpw4b8DS" "bDlXmHuICiiRYgLOORrBpfZgIqFMTfq8")
CL-USER> 

Usage

The default generator creates 32-character long base 62 (a-z,A-Z,0-9) tokens and seeds itself with (isaac:init-kernel-seed) (which won't work on Windows because it pulls from /dev/urandom or /dev/arandom).

make-generator

takes three keyword arguments that let you specify its alphabet, token length and initial seed. Returns a closure that returns the next generated token (and can optionally be re-initialized with a new seed).

Example invocations:

(session-token:make-generator)
(session-token:make-generator :token-length 64)
(session-token:make-generator :alphabet "0123456789abcdef")
(session-token:make-generator :initial-seed (cl-isaac:init-kernel-seed) :token-length 64 :alphabet "0123456789abcdef")

Example use:

SESSION-TOKEN> (defvar generator (session-token:make-generator))
GENERATOR
SESSION-TOKEN> (funcall generator)
"iyyiGgbALDzVCC7qX27oXR7pP89ZKOqy"
SESSION-TOKEN> (funcall generator (cl-isaac:init-kernel-seed))
"WdUBwtFG9sT49pEgkb3qTqiK2FzmYefm" ;; generated with the new seed
SESSION-TOKEN>
char-range

takes a series of range terms and additional keyword arguments for specifc extra chars to be added or excluded.

You can pass neither, either or both. If you pass conflicting :not and :plus arguments, :plus takes precedence, and the specified characters will be present in the result.

Example:

(char-range (#\a :to #\z))
(char-range (#\a :to #\z #\A :to #\Z #\0 :to #\9))
(char-range (#\a :to #\z #\A :to #\Z #\1 :to #\9) :not "O0lI1")
(char-range (#\a :to #\z #\1 :to #\9) :plus ",.;:!?")

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 session-token

Author

Inaimathi <leo.zovic@gmail.com>

License

BSD license: you can do anything you want with it (but no warranty).

Description

Simple session token generation library

Dependency

cl-isaac

Source

session-token.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 session-token.asd

Location

session-token.asd

Systems

session-token (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 session-token/package.lisp

Parent

session-token (system)

Location

package.lisp

Packages

session-token


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 session-token/util.lisp

Dependency

package.lisp (file)

Parent

session-token (system)

Location

util.lisp

Exported Definitions

char-range (macro)

Internal Definitions

next-power-of-two (method)


Previous: , Up: Lisp files   [Contents][Index]

3.1.4 session-token/session-token.lisp

Dependency

util.lisp (file)

Parent

session-token (system)

Location

session-token.lisp

Exported Definitions

make-generator (function)

Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 session-token

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: char-range (&rest START-TO-END-PAIRS) &key PLUS NOT
Package

session-token

Source

util.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: make-generator &key INITIAL-SEED ALPHABET TOKEN-LENGTH
Package

session-token

Source

session-token.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *default-alphabet*
Package

session-token

Source

session-token.lisp (file)

Special Variable: *default-token-length*
Package

session-token

Source

session-token.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Generic functions

Generic Function: next-power-of-two NUM
Package

session-token

Methods
Method: next-power-of-two (NUM number)
Source

util.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   S  
Index Entry  Section

F
File, Lisp, session-token.asd: The session-token<dot>asd file
File, Lisp, session-token/package.lisp: The session-token/package<dot>lisp file
File, Lisp, session-token/session-token.lisp: The session-token/session-token<dot>lisp file
File, Lisp, session-token/util.lisp: The session-token/util<dot>lisp file

L
Lisp File, session-token.asd: The session-token<dot>asd file
Lisp File, session-token/package.lisp: The session-token/package<dot>lisp file
Lisp File, session-token/session-token.lisp: The session-token/session-token<dot>lisp file
Lisp File, session-token/util.lisp: The session-token/util<dot>lisp file

S
session-token.asd: The session-token<dot>asd file
session-token/package.lisp: The session-token/package<dot>lisp file
session-token/session-token.lisp: The session-token/session-token<dot>lisp file
session-token/util.lisp: The session-token/util<dot>lisp file

Jump to:   F   L   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   F   G   M   N  
Index Entry  Section

C
char-range: Exported macros

F
Function, make-generator: Exported functions

G
Generic Function, next-power-of-two: Internal generic functions

M
Macro, char-range: Exported macros
make-generator: Exported functions
Method, next-power-of-two: Internal generic functions

N
next-power-of-two: Internal generic functions
next-power-of-two: Internal generic functions

Jump to:   C   F   G   M   N  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*default-alphabet*: Internal special variables
*default-token-length*: Internal special variables

S
Special Variable, *default-alphabet*: Internal special variables
Special Variable, *default-token-length*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, session-token: The session-token package

S
session-token: The session-token system
session-token: The session-token package
System, session-token: The session-token system

Jump to:   P   S