Closed enricovianello closed 1 year ago
This limit comes from MySQL column prefix limits. I think it is really not optimal to create such a huge index that basically double the size of access_token
table a we already know from Halloween incident that this can leads to very poor IAM performance.
Why do you even create index on token content, this seems to me like not very optimal design choice considering you should be able to quickly search any token in the database by jti
. Instead of trying to cover whole token_value
size by index it would be better to fix code not to rely on this index and get rid of at_tv_idx
.
The index on token_value
is due to the UNIQUE constraint.
Using jti
(ref) could be a solution. I was thinking about adding an hash
type column to access_token
table, generated directly from token_value
:
ALTER TABLE access_token DROP INDEX token_value; # remove current index
ALTER TABLE access_token ADD COLUMN token_value_hash hash UNIQUE NOT NULL CONSTRAINT default_token_hash DEFAULT SHA1(token_value);
and apply the UNIQUE constraint to that. This value for sure is similar of evaluating a jti and store it separately, indexed. What do you think @vokac @giacomini ?
This seems to me like a most simple solution with minimal code updates that would allow us to drop huge token_value
index (assuming there are no later changes in this column) and it is more universal than relying on optional jti
(this claim is required only by WLCG profile).
We should still consider more ambitious project of dropping whole token_value
column from access token table, because it seems to me we should not really need full access token stored in the database.
The hash of the full token is ok. Note however that we already have a hash available, which is the signature component of the token.
This is an example of the error got during a token exchange:
This is due to the fact that:
but it's created for only the first 767 characters.
We need to understand the reason of this limitation (inherited from mitreId) and if this limitation can be removed or not.