Skip to content

Commit e0f1a23

Browse files
committed
fix: check expires_at when get grant public key
1 parent b6ac894 commit e0f1a23

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

persistence/sql/persister_grant_jwk.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ func (p *Persister) GetPublicKey(ctx context.Context, issuer string, subject str
137137
tableName += "@hydra_oauth2_trusted_jwt_bearer_issuer_nid_uq_idx"
138138
}
139139

140-
sql := fmt.Sprintf(`SELECT key_set FROM %s WHERE key_id = ? AND nid = ? AND issuer = ? AND (subject = ? OR allow_any_subject IS TRUE) LIMIT 1`, tableName)
140+
expiresAt := "expires_at > NOW()"
141+
if p.Connection(ctx).Dialect.Name() == "sqlite3" {
142+
expiresAt = "expires_at > datetime('now')"
143+
}
144+
145+
sql := fmt.Sprintf(`SELECT key_set FROM %s WHERE key_id = ? AND nid = ? AND issuer = ? AND (subject = ? OR allow_any_subject IS TRUE) AND %s LIMIT 1`, tableName, expiresAt)
141146
query := p.Connection(ctx).RawQuery(sql,
142147
keyId, p.NetworkID(ctx), issuer, subject,
143148
)

0 commit comments

Comments
 (0)