Hi,
I am writing a plugin which generates random tokens and stores them in vault in kv for purposes of adding auth backend to NSQD.
I am looking for a way to get the username associated with the person using my plugin for auditing purposes. My workflow is as follows
- get vault token using ldap
- login to vault using token
- request token from my plugin
- plugin generates token and saves it as KV.
I know my ldap username is tracked along with the token i use because it's in audit logs:
1) LDAP Auth
{
"time" : "2018-07-11T17:35:51.576117868Z" ,
"type" : "request" ,
"auth" : {
"client_token" : "" ,
"accessor" : "" ,
"display_name" : "" ,
"policies" : null ,
"metadata" : null ,
"entity_id" : ""
},
"request" : {
"id" : "5ea5d12b-0e7b-a571-cc2a-34e909573aed" ,
"operation" : "update" ,
"client_token" : "" ,
"client_token_accessor" : "" ,
"path" : "auth/ldap/login/seba" ,
"data" : {
"password" : "hmac-sha256:f3066947b57b2468ac49cf8b9fa916fa78112e60d12d317aa348c0237231ee74"
},
"policy_override" : false ,
"remote_address" : "172.25.44.136" ,
"wrap_ttl" : 0,
"headers" : {}
},
"error" : ""
}
|
"time"
:
"2018-07-11T17:35:51.953444112Z"
,
"type"
:
"response"
,
"auth"
: {
"client_token"
:
"hmac-sha256:b4e71e110ce6268a3d7b4a983d97cbf5ad78e59b0e3def8894c2e0d85ef64577"
,
"accessor"
:
"hmac-sha256:f9812acd0943f707df02fcc6c222417aaeeaf8d5c6acdb522330bab3b9aeb428"
,
"display_name"
:
"ldap-seba"
,
"policies"
: [
"default"
,
"ldap-example"
,
"nsq-access"
,
"platform-cassandra"
,
"plugin-provisioner"
,
"sre-cassandra"
,
"sre-vault-provision"
,
"token-creator"
],
"metadata"
: {
"username"
:
"seba"
},
"entity_id"
:
"40201dd2-8f97-f9d1-9416-b5188e86c080"
},
"request"
: {
"id"
:
"5ea5d12b-0e7b-a571-cc2a-34e909573aed"
,
"operation"
:
"update"
,
"client_token"
:
""
,
"client_token_accessor"
:
""
,
"path"
:
"auth/ldap/login/seba"
,
"data"
: {
"password"
:
"hmac-sha256:f3066947b57b2468ac49cf8b9fa916fa78112e60d12d317aa348c0237231ee74"
},
"policy_override"
:
false
,
"remote_address"
:
"172.25.44.136"
,
"wrap_ttl"
: 0,
"headers"
: {}
},
"response"
: {
"auth"
: {
"client_token"
:
"hmac-sha256:b4e71e110ce6268a3d7b4a983d97cbf5ad78e59b0e3def8894c2e0d85ef64577"
,
"accessor"
:
"hmac-sha256:f9812acd0943f707df02fcc6c222417aaeeaf8d5c6acdb522330bab3b9aeb428"
,
"display_name"
:
"ldap-seba"
,
"policies"
: [
"default"
,
"ldap-example"
,
"nsq-access"
,
"platform-cassandra"
,
"plugin-provisioner"
,
"sre-cassandra"
,
"sre-vault-provision"
,
"token-creator"
],
"metadata"
: {
"username"
:
"seba"
},
"entity_id"
:
""
}
},
"error"
:
""
}
2) Access my plugin at nsq/get-token so that it generates a token for me
vault write nsq/get-token topics=topic1,topic2
"time"
:
"2018-07-11T17:27:24.563804807Z"
,
"type"
:
"request"
,
"auth"
: {
"client_token"
:
"hmac-sha256:f1f5d061564198deeeab296b71c1d84d3a8fc1a45c7741e286031d67d2edd01f"
,
"accessor"
:
"hmac-sha256:85db794c59cf29abd7bbc4ecfd2e4e46cf07b92cc73814eca7f75e2aa0637ed9"
,
"display_name"
:
"ldap-seba"
,
"policies"
: [
"default"
,
"ldap-example"
,
"nsq-access"
,
"platform-cassandra"
,
"plugin-provisioner"
,
"sre-cassandra"
,
"sre-vault-provision"
,
"token-creator"
],
"metadata"
: {
"username"
:
"seba"
},
"entity_id"
:
"40201dd2-8f97-f9d1-9416-b5188e86c080"
},
"request"
: {
"id"
:
"c495e073-cb6f-a991-49a9-4b3daf86ae29"
,
"operation"
:
"update"
,
"client_token"
:
"hmac-sha256:f1f5d061564198deeeab296b71c1d84d3a8fc1a45c7741e286031d67d2edd01f"
,
"client_token_accessor"
:
"hmac-sha256:85db794c59cf29abd7bbc4ecfd2e4e46cf07b92cc73814eca7f75e2aa0637ed9"
,
"path"
:
"nsq/get-token"
,
"data"
: {
"topics"
:
"hmac-sha256:1e52fa0bf5c404d488baff921a5d5accda931d69373f3a3c07768f165c713609"
},
"policy_override"
:
false
,
"remote_address"
:
"172.25.44.136"
,
"wrap_ttl"
: 0,
"headers"
: {}
},
"error"
:
""
}
As you see in the audit log entry above, Vault logs my ldap username (seba) in this request. So it keeps track of the user name at this stage. Is there a way for me to get access to the username (metadata/username) above from inside of the plugin?
Thanks!