2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2015-03-30 21:23:32 +00:00
|
|
|
package logical
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/tls"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Connection represents the connection information for a request. This
|
|
|
|
// is present on the Request structure for credential backends.
|
|
|
|
type Connection struct {
|
|
|
|
// RemoteAddr is the network address that sent the request.
|
2017-02-16 20:15:02 +00:00
|
|
|
RemoteAddr string `json:"remote_addr"`
|
2015-03-30 21:23:32 +00:00
|
|
|
|
Add remote_port in the audit logs when it is available (#12790)
* Add remote_port in the audit logs when it is available
The `request.remote_port` field is now present in the audit log when it
is available:
```
{
"time": "2021-10-10T13:53:51.760039Z",
"type": "response",
"auth": {
"client_token": "hmac-sha256:1304aab0ac65747684e1b58248cc16715fa8f558f8d27e90fcbcb213220c0edf",
"accessor": "hmac-sha256:f8cf0601dadd19aac84f205ded44c62898e3746a42108a51105a92ccc39baa43",
"display_name": "root",
"policies": [
"root"
],
"token_policies": [
"root"
],
"token_type": "service",
"token_issue_time": "2021-10-10T15:53:44+02:00"
},
"request": {
"id": "829c04a1-0352-2d9d-9bc9-00b928d33df5",
"operation": "update",
"mount_type": "system",
"client_token": "hmac-sha256:1304aab0ac65747684e1b58248cc16715fa8f558f8d27e90fcbcb213220c0edf",
"client_token_accessor": "hmac-sha256:f8cf0601dadd19aac84f205ded44c62898e3746a42108a51105a92ccc39baa43",
"namespace": {
"id": "root"
},
"path": "sys/audit/file",
"data": {
"description": "hmac-sha256:321a1d105f8c6fd62be4f34c4da4f0e6d1cdee9eb2ff4af0b59e1410950fe86b",
"local": false,
"options": {
"file_path": "hmac-sha256:2421b5bf8dab1f9775b2e6e66e58d7bca99ab729f3f311782fda50717eee55b3"
},
"type": "hmac-sha256:30dff9607b4087e3ae6808b4a3aa395b1fc064e467748c55c25ddf0e9b150fcc"
},
"remote_address": "127.0.0.1",
"remote_port": 54798
},
"response": {
"mount_type": "system"
}
}
```
Closes https://github.com/hashicorp/vault/issues/7716
* Add changelog entry
* Empty commit to trigger CI
* Add test and explicit error handling
* Change temporary file pattern in test
2022-01-26 23:47:15 +00:00
|
|
|
// RemotePort is the network port that sent the request.
|
|
|
|
RemotePort int `json:"remote_port"`
|
|
|
|
|
2015-03-30 21:23:32 +00:00
|
|
|
// ConnState is the TLS connection state if applicable.
|
2017-10-23 20:42:56 +00:00
|
|
|
ConnState *tls.ConnectionState `sentinel:""`
|
2015-03-30 21:23:32 +00:00
|
|
|
}
|