Skip to content

Authorization JDBC column limits too small #557

Closed
@mikesaurus

Description

@mikesaurus

Describe the bug
The oauth2_authorization.attributes, .access_token_metadata, and .oidc_token_metadata database columns are limited to 4000, 2000, and 2000 characters respectively. When introducing a JWT customizer, the token claims set can increase the number of characters required to be stored in the two metadata columns above 2000 characters. Also, the attributes columns includes the authorization request object, which contains "additional parameters" from the authorization request that could consume 2000+ chars by themselves. Any of these situations could result in an error such as:

org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [UPDATE oauth2_authorization SET registered_client_id = ?, principal_name = ?, authorization_grant_type = ?, attributes = ?, state = ?, authorization_code_value = ?, authorization_code_issued_at = ?, authorization_code_expires_at = ?, authorization_code_metadata = ?, access_token_value = ?, access_token_issued_at = ?, access_token_expires_at = ?, access_token_metadata = ?, access_token_type = ?, access_token_scopes = ?, oidc_id_token_value = ?, oidc_id_token_issued_at = ?, oidc_id_token_expires_at = ?, oidc_id_token_metadata = ?, refresh_token_value = ?, refresh_token_issued_at = ?, refresh_token_expires_at = ?, refresh_token_metadata = ? WHERE id = ?]; Value too long for column "ACCESS_TOKEN_METADATA VARCHAR(2000)": "'{""@class"":""java.util.Collections$UnmodifiableMap"",""metadata.token.claims"":{""@class"":""java.util.Collections$UnmodifiableMap"",""su... (2119)"

To Reproduce
The simplest method would be to add a JwtCustomizer to the default implementation that adds a single custom claim with a value containing >2000 chars to the JWT context claims.

Expected behavior
Any database columns that store data that could either be customized (JWT/token metadata) or provided by an external party such as the client and/or user should not make any assumption as to the number of characters that the value may contain and should not be defined as VARCHAR data types with explicit limits, but rather should be defined as CLOB data types. This includes the three columns mentioned above and any others that might fall under this same scenario of unknown/undefined value length.

Sample
@Bean public OAuth2TokenCustomizer<JwtEncodingContext> oAuth2TokenCustomizer() { return (context) -> { final char[] claimValue = new char[2000]; for (int i = 0; i < 2000; i++) { claimValue[i] = 'a'; } context.getClaims().claim("custom_claim", claimValue); }; }

Metadata

Metadata

Assignees

Labels

status: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions