Skip to content

Commit d2623fd

Browse files
EFRS-1286: Added changes to the expiration column change set in order to remove old tokens that do not have an expiration column
1 parent 3836c4f commit d2623fd

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

java/admin/src/main/java/com/exadel/frs/system/security/CustomJdbcTokenStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class CustomJdbcTokenStore extends JdbcTokenStore {
2222

2323
private static final String INSERT_ACCESS_TOKEN_WITH_EXPIRATION_SQL = "insert into oauth_access_token (token_id, token, authentication_id, user_name, client_id, authentication, refresh_token, expiration) values (?, ?, ?, ?, ?, ?, ?,?)";
2424
private static final String INSERT_REFRESH_TOKEN_WITH_EXPIRATION_SQL = "insert into oauth_refresh_token (token_id, token, authentication, expiration) values (?, ?, ?, ?)";
25-
private static final String REMOVE_EXPIRED_ACCESS_TOKENS_SQL = "delete from oauth_access_token where expiration is null or expiration < ?";
26-
private static final String REMOVE_EXPIRED_REFRESH_TOKENS_SQL = "delete from oauth_refresh_token where expiration is null or expiration < ?";
25+
private static final String REMOVE_EXPIRED_ACCESS_TOKENS_SQL = "delete from oauth_access_token where expiration < ?";
26+
private static final String REMOVE_EXPIRED_REFRESH_TOKENS_SQL = "delete from oauth_refresh_token where expiration < ?";
2727

2828
private final JdbcTemplate jdbcTemplate;
2929
private final AuthenticationKeyGenerator authenticationKeyGenerator;

java/admin/src/main/resources/db/changelog/db.changelog-0.2.4.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ databaseChangeLog:
33
id: expand-oauth_access_token-and-oauth_refresh_token-with-expiration-column
44
author: Volodymyr Bushko
55
changes:
6+
# delete all old tokens that do not have an expiration column
7+
- delete:
8+
tableName: oauth_access_token
9+
- delete:
10+
tableName: oauth_refresh_token
11+
# add an expiration column
612
- addColumn:
713
tableName: oauth_access_token
814
columns:
@@ -15,3 +21,10 @@ databaseChangeLog:
1521
- column:
1622
name: expiration
1723
type: timestamp
24+
# add a non-null constraint to the expiration column
25+
- addNotNullConstraint:
26+
tableName: oauth_access_token
27+
columnName: expiration
28+
- addNotNullConstraint:
29+
tableName: oauth_refresh_token
30+
columnName: expiration

java/api/src/test/resources/db/changelog/db.changelog-0.2.4.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ databaseChangeLog:
33
id: expand-oauth_access_token-and-oauth_refresh_token-with-expiration-column
44
author: Volodymyr Bushko
55
changes:
6+
# delete all old tokens that do not have an expiration column
7+
- delete:
8+
tableName: oauth_access_token
9+
- delete:
10+
tableName: oauth_refresh_token
11+
# add an expiration column
612
- addColumn:
713
tableName: oauth_access_token
814
columns:
@@ -15,3 +21,10 @@ databaseChangeLog:
1521
- column:
1622
name: expiration
1723
type: timestamp
24+
# add a non-null constraint to the expiration column
25+
- addNotNullConstraint:
26+
tableName: oauth_access_token
27+
columnName: expiration
28+
- addNotNullConstraint:
29+
tableName: oauth_refresh_token
30+
columnName: expiration

0 commit comments

Comments
 (0)