Skip to content
This repository was archived by the owner on Aug 26, 2026. It is now read-only.
This repository was archived by the owner on Aug 26, 2026. It is now read-only.

org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService should support postgres DB as an implementation #2321

Description

@solidjb

Expected Behavior
An application can choose a PostgresDB backend to implement org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService. This would include cloud offerings such as AWS Aurora DSQL.

Current Behavior
Postgres does not support BLOB (sql type 2004) and CLOB (sql type 2005) types, they use BYTEA (sql type -2) instead. The class JdbcOAuth2AuthorizationService does not have any support for the BYTEA column type, and therefore fails to save or retrieve data to and from the db appropriately.

Context
In order to fix this, I copied the class org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService into my project and modified two methods:

  1. org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService.AbstractOAuth2AuthorizationRowMapper#getLobValue
  2. org.springframework.security.oauth2.server.authorization.JdbcOAuth2AuthorizationService.LobCreatorArgumentPreparedStatementSetter#doSetValue

In both methods, I added support for the BYTEA column type, and treated the data similar to a BLOB type.
for getLobValue, I did this:
if (Types.BINARY == columnMetadata.getDataType()) { byte[] columnValueBytes = this.lobHandler.getBlobAsBytes(rs, columnName); if (columnValueBytes != null) { columnValue = new String(columnValueBytes, StandardCharsets.UTF_8); } }

and for doSetValue, I did this:
`
if (paramValue.getSqlType() == Types.BINARY) {
byte[] valueBytes = null;
if (paramValue.getValue() != null) {

    Object value = paramValue.getValue();

    if (value instanceof byte[] byteArray) {
        valueBytes = byteArray;
    }
    else if (value instanceof String stringValue) {
        valueBytes = stringValue.getBytes(StandardCharsets.UTF_8);
    }
}
this.lobCreator.setBlobAsBytes(ps, parameterPosition, valueBytes);
return;

}
`
There could be more to do, but I haven't discovered anything else at the moment.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions