crypto-token-0.1.1: crypto tokens
Safe HaskellSafe-Inferred
LanguageHaskell2010

Crypto.Token

Description

Encrypted tokens/tickets to keep state in the client side.

Synopsis

Configuration

data Config Source #

Configuration for token manager.

Instances

Instances details
Show Config Source # 
Instance details

Defined in Crypto.Token

Eq Config Source # 
Instance details

Defined in Crypto.Token

Methods

(==) :: Config -> Config -> Bool #

(/=) :: Config -> Config -> Bool #

interval :: Config -> Int Source #

The interval to generate a new secret and remove the oldest one in seconds.

tokenLifetime :: Config -> Int Source #

The token lifetime, that is, tokens can be decrypted in this period.

defaultConfig :: Config Source #

Default configuration to update secrets in 30 minutes (1,800 seconds) and token lifetime is 2 hours (7,200 seconds)

>>> defaultConfig
Config {interval = 1800, tokenLifetime = 7200}

Token manager

data TokenManager Source #

The abstract data type for token manager.

spawnTokenManager :: Config -> IO TokenManager Source #

Spawning a token manager.

killTokenManager :: TokenManager -> IO () Source #

Killing a token manager.

Encryption and decryption

encryptToken :: TokenManager -> ByteString -> IO ByteString Source #

Encrypting a target value to get a token.

decryptToken :: TokenManager -> ByteString -> IO (Maybe ByteString) Source #

Decrypting a token to get a target value.