Skip to content

Commit 0e1423d

Browse files
committed
Added common OAuth2 keys to default body obfuscation config
Updated Testing section in README
1 parent 6d0ab5e commit 0e1423d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

Diff for: CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [v1.1.x (Unreleased)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.1.0...main)
44

5-
- ...
5+
- Added common OAuth2 keys `access_token,refresh_token,client_secret` to default body obfuscation configuration.
66

77
## [v1.1.0 (2023-11-09)](https://github.com/onlime/laravel-http-client-global-logger/compare/v1.0.2...v1.1.0)
88

Diff for: README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Both packages provide a different feature set and have those advantages:
165165
- global logging
166166
- auto-configured log channel `http-client` to log to a separate `http-client.log` file
167167
- Full support of [Guzzle MessageFormatter](https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php) variable substitutions for highly customized log messages.
168-
- obfuscation of credentials in HTTP Client requests
168+
- basic obfuscation of credentials in HTTP Client requests
169169
- [bilfeldt/laravel-http-client-logger](https://github.com/bilfeldt/laravel-http-client-logger)
170170
- conditional logging using `logWhen($condition)`
171171
- filtering of logs by HTTP response codes
@@ -175,27 +175,34 @@ So, my recommendation: If you need global logging without any extra configuratio
175175

176176
## Caveats
177177

178-
- This package currently uses two different implementations for logging. In the preferred variant 1 (global logging), it is currently not possible to configure the [log channel name](https://laravel.com/docs/logging#configuring-the-channel-name) which defaults to current environment, such as `production` or `local`. If you with to use Laravel HTTP Client to access multiple different external APIs, it is nice to explicitely distinguish between them by different log channel names.
178+
- This package currently uses two different implementations for logging. In the preferred variant 1 or 3 (global logging), it is currently not possible to configure the [log channel name](https://laravel.com/docs/logging#configuring-the-channel-name) which defaults to current environment, such as `production` or `local`. If you with to use Laravel HTTP Client to access multiple different external APIs, it is nice to explicitly distinguish between them by different log channel names.
179179

180180
As a workaround, I have implemented another way of logging through `Http::log()` method as mixin. But of course, we should combine both variants into a single one for a cleaner codebase.
181181

182-
- Very basic obfuscation support using regex with lookbehind assertions (e.g. `/(?<=Authorization:\sBearer ).*/m`, modifying formatted log output. It's currently not possible to directly modify request headers or JSON data in request body.
182+
- Obfuscation
183+
184+
- Body keys: Very basic obfuscation support using regex with lookbehind assertions (e.g. `/(?<="token":").*(?=")/mU`, modifying formatted log output. It's currently not possible to directly modify JSON data in request body.
185+
186+
- No obfuscation of query params, e.g. on a POST request to an OAuth2 token endpoint.
187+
188+
- Obfuscation currently only works in variant 1 or 3 (global logging).
183189

184-
- Obfuscation currently only works in variant 1 (global logging).
185190

186191
## Testing
187192

188-
TBD.
193+
Currently, there is very basic code/test coverage. We're using [PEST](https://pestphp.com/), so just run all tests like so:
189194

190-
(any help appreciated!)
195+
```bash
196+
$ ./vendor/bin/pest
197+
```
191198

192199
## Changes
193200

194201
All changes are listed in [CHANGELOG](CHANGELOG.md)
195202

196203
## Authors
197204

198-
Author of this shitty little package is **[Philip Iezzi (Onlime GmbH)](https://www.onlime.ch/)**.
205+
Made with ❤️ by **[Philip Iezzi (Onlime GmbH)](https://www.onlime.ch/)**.
199206

200207
## License
201208

Diff for: config/http-client-global-logger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
)),
105105
'body_keys' => explode(',', env(
106106
'HTTP_CLIENT_GLOBAL_LOGGER_OBFUSCATE_BODY_KEYS',
107-
'pass,password,token,apikey'
107+
'pass,password,token,apikey,access_token,refresh_token,client_secret'
108108
)),
109109
],
110110
];

0 commit comments

Comments
 (0)