- troclapi
Basic api for trocla usage
Show Trocla documentation for all usage
Please, show trocla documatation for all params
Login with Ldap or admin token
With token:
{
"token": "LFchdkKV0wSa6yuprnxlA8UAPdMLaCXu"
}
If you doesn't use cookie with token authentification, you can use header X-Token. Exemple:
curl -s -XGET 0.0.0.0:4567/v1/key/mykey0/plain -H 'X-Token: ZOW7JrxW4S8yuJSuCWfh28uJTRQ6RPUQToDZ4l8otp2vRSl9A5gt0oQewjkZMuM9' | jq
{
"format": "plain",
"value": "QObjamgUMLczBhmfgc1R",
"success": true
}
Ldap connection
{
"username": "my.user",
"password": "mypass"
}
Create key with specific value
json example:
# Optional
{
"length": 20,
"charset": "alphanumeric"
}
Create multiple key with specific value
json example:
{
"length": 20,
"charset": "alphanumeric",
"format": "plain", # Using by default
"keys": [
{
"key": "mykey0",
"length": "20",
"format": "mysql"
},
{
"key": "mykey1"
}
]
}
Get key value
Using render format in url for select format (example: /v1/my_x509_key/x509/keyonly)
Get multiple key
json example:
{
"format": "plain",
"keys": [
{
"key": "mykey0"
},
{
"key": "mykey1",
"format": "x509",
"render": "certonly"
}
]
}
Set key
json example:
{
"value": "myvalue"
}
Set multiple key
json example:
{
"format": "plain", # Default value
"keys": [
{
"key": "mykey0",
"value": "myvalue0",
"format": "mysql"
},
{
"key": "mykey1",
"value": "myvalue1",
}
]
}
Reset key
json example:
# Optional
{
"length": 20,
"charset": "alphanumeric"
}
Reset multiple key
json example:
{
"format": "plain", # Default value
"length": 20,
"keys": [
{
"key": "mykey0",
"length": 32,
"format": "mysql"
},
{
"key": "mykey1",
}
]
}
Delete key
Delete mutiple key
json example:
{
"format": "plain", # Default value
"keys": [
{
"key": "mykey0",
"format": "mysql"
},
{
"key": "mykey1",
}
]
}
Search key with ruby regex format
Return available trocla formats
Return if formats is available
Return avalaible format for a specific key
Return if format is available for this key
Return available format for multi key
json example:
{
"keys": [
"mykeys0",
"mykey1"
]
}
# curl -s troclapi.local/login -XPOST -d '{"username": "my.user", "password": "secret"}' -c /tmp/cookie | jq
{
"success": true
}
# curl -s -b /tmp/cookie troclapi.local/v1/key/toto/plain | jq
{
"format": "plain",
"value": "toto",
"success": true
}
# curl -s -b /tmp/cookie -XPOST troclapi.local/v1/key/mysqlkey/mysql -d '' | jq
{
"format": "mysql",
"value": "*2B74D8F42C6EC26269106199686D2386A2E47D18",
"success": true
}
# curl -s -b /tmp/cookie -XPOST troclapi.local/v1/key/mysqlkey/plain -d '' | jq
{
"format": "plain",
"value": "ze.4D8{TM)*]m0CF",
"success": true
}
# curl -s -b /tmp/cookie -XPOST troclapi.local/v1/get/ -d '{"keys": [{"key": "toto"},{"key": "titi"},{"key": "mysqlkey", "format": "mysql"},{"key": "mysqlkey", "format": "plain"}]}' | jq
[
{
"format": "plain",
"value": "toto",
"success": true,
"key": "toto"
},
{
"error": "Key not found on this format",
"success": false,
"key": "titi"
},
{
"format": "mysql",
"value": "*2B74D8F42C6EC26269106199686D2386A2E47D18",
"success": true,
"key": "mysqlkey"
},
{
"format": "plain",
"value": "ze.4D8{TM)*]m0CF",
"success": true,
"key": "mysqlkey"
}
]
- gem install bundle
- bundle install
Available Dockerfile example on docker_example repository
docker build -t troclapi .
docker run -d -p 5678:5678 -v /var/log/troclapi:/var/log/troclapi troclapi
Add api configuration on trocla configuration file. The troclarc file can be define with environment variable TROCLARC_FILE
.
api:
setting: # Sinatra setting
:bind: 0.0.0.0
:port: 5678
:logging: Logger::INFO
actions: # Allow trocla actions. For all remove this params
- formats
- get
- search
tokens:
dev: LFchdkKV0wSa6yuprnxlA8UAPdMLaCXu
ansible: TRFgkHDFgh65KJHGhf5jHJg5KJgjhvg
ldap:
:host: '127.0.0.1'
:base: 'OU=People,DC=local'
:filter: '(&(sAMAccountName={username}))' # Using {username} for the username
:auth:
:method: :simple
:username: 'CN=service.user,OU=Services,DC=local'
:password: secret
Show Sinatra documentation for available settings, and Net::LDAP for ldap options (default filter sAMAccountName=username)