Crypto.Token

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 #

Configuration for token manager.

#### Instances

Instances details

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

defaultConfig :: Config #

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 #

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

tokenLifetime :: Config -> Int #

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

threadName :: Config -> String #

# Token manager

data TokenManager #

The abstract data type for token manager.

spawnTokenManager :: Config -> IO TokenManager #

Spawning a token manager.

killTokenManager :: TokenManager -> IO () #

Killing a token manager.

# Encryption and decryption

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

Encrypting a target value to get a token.

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

Decrypting a token to get a target value.