crypto-token-0.1.2: crypto tokens

Safe Haskell | None
Language | Haskell2010

Crypto.Token

Contents

- Configuration
- Token manager
- Encryption and decryption

Description

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

Synopsis

- data Config
- defaultConfig :: Config
- interval :: Config -> Int
- tokenLifetime :: Config -> Int
- threadName :: Config -> String
- data TokenManager
- spawnTokenManager :: Config -> IO TokenManager
- killTokenManager :: TokenManager -> IO ()
- encryptToken :: TokenManager -> ByteString -> IO ByteString
- decryptToken :: TokenManager -> ByteString -> IO (Maybe ByteString)

# Configuration

data Config Source #

Configuration for token manager.

#### Instances

Instances details

Show Config Source # |
Instance details Defined in Crypto.Token Methods showsPrec :: Int -> Config -> ShowS Source # show :: Config -> String Source # showList :: [Config] -> ShowS Source #
Eq Config Source # |
Instance details Defined in Crypto.Token Methods (==) :: Config -> Config -> Bool Source # (/=) :: Config -> Config -> Bool Source #

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}

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.

threadName :: Config -> String Source #

# 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.