Repository navigation
HTTP logs: Redact OAuth tokens and client secrets in bodies - #282
Open
paolostivanin wants to merge 1 commit into
Open
paolostivanin wants to merge 1 commit into
paolostivanin wants to merge 1 commit into
Conversation
With HTTP logs enabled, only the Authorization header was redacted. The bodies were logged as they are, so the logs contained the token requests (refresh token, authorization code, PKCE verifier, client secret) and the token responses (access, refresh and id token), as well as the client_secret of the client registration response. The existing redaction setting (redact_auth_header_logs, true by default) now also masks these fields in form and JSON bodies. With the setting off, the logs stay complete for debugging. "code" is only masked in form bodies, since Graph API errors carry a "code" field too. The flag is renamed redactSecrets and the MDM strings describe what it covers now. The MDM key does not change. kotlin-reflect is added to the library unit tests, the interceptor needs it to serialize its logs (the app gets it from opencloudData).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With "HTTP logs" enabled,
LogInterceptoronly redacted theAuthorizationheader. Request and response bodies were logged as they are, so the logs contained:client_secretThese logs are meant to be shared for support. A 30-day refresh token in them gives access to the account.
Changes
redact_auth_header_logs,trueby default, configurable via MDM and branding) now also masks these fields in form and JSON bodies. With the setting off, the logs stay complete for debugging.codeis only masked in form bodies (token requests), since Graph API errors carry acodefield too.LogInterceptor.redactAuthHeaderis renamed toredactSecrets, and the MDM strings describe what it covers now. The MDM key does not change.Follow-up of #237, which stops the app's own log statements from writing tokens.
Testing
LogInterceptorTest: a refresh token request through the interceptor against MockWebServer, checking the captured logs with redaction on and off, plus the authorization code grant, the client registration response, and a Graph-stylecodefield that is kept.kotlin-reflectis added to the library unit test classpath: the interceptor serializes its logs withKotlinJsonAdapterFactory, and the library excludes it (the app gets it fromopencloudData).