Page MenuHomePhabricator

Consider disabling personal access token forced expiration
Closed, ResolvedPublicFeature

Description

I suppose at least theoretically, we could have a service that rotates tokens, although they're definitely scattered around a bunch of places...

GitLab's paywalled version allows creating "service accounts" and loosens restrictions so that these accounts can have non-expiring personal access tokens.

GitLab 17.3 quietly added a configuration option in all tiers to disable forced token expiration dates.

Admin areaGeneralAccount and limit:

Screenshot 2025-02-07 at 18.05.09.png (198×1 px, 71 KB)

I think we should toggle the forced expiration off in the gitlab.wikimedia.org instance. Once the switch is off we could either figure out how to update the database directly to remove the expiration date from tokens known to be used by infrastructure bots or rotate tokens everywhere to get back to non-expiring tokens.

Details

TitleReferenceAuthorSource BranchDest Branch
disable forced token expiryrepos/releng/gitlab-settings!68brennenwork/T385930-disable-token-expirymain
Customize query in GitLab

Event Timeline

This task was discussed in the 2025-02-12 RelEng check-in meeting. I believe the consensus there was that we should disable the setting and also follow up by extending/removing the expiration date of active tokens directly via the rails console. Does that sound like what was concluded to you as well @brennen?

This task was discussed in the 2025-02-12 RelEng check-in meeting. I believe the consensus there was that we should disable the setting and also follow up by extending/removing the expiration date of active tokens directly via the rails console. Does that sound like what was concluded to you as well @brennen?

Yep, concur.

Looks like for the settings API we want:

  • require_personal_access_token_expiry
  • service_access_tokens_expiration_enforced

Looks like there's a tool for handling expiration removal: https://docs.gitlab.com/administration/raketasks/tokens/ - will experiment with that.

Mentioned in SAL (#wikimedia-releng) [2025-02-21T22:54:12Z] <brennen> gitlab: removing expiration date for 14 tokens expiring in 2025 (T385930)

brennen moved this task from Backlog to Done or Declined on the User-brennen board.

I ran:

brennen@gitlab2002:~$ sudo gitlab-rake gitlab:tokens:analyze

To get a summary of tokens, and then:

brennen@gitlab2002:~$ sudo gitlab-rake gitlab:tokens:edit

I removed the expiry from 14 personal access tokens in total expiring in 2025. I'm operating on the assumption that stuff which already expired at the end of 2024 has probably been fixed by now. We can maybe revisit if there's anything lingering.

I removed the expiry from 14 personal access tokens in total expiring in 2025. I'm operating on the assumption that stuff which already expired at the end of 2024 has probably been fixed by now. We can maybe revisit if there's anything lingering.

Yesterday gitlab emailed the https://gitlab.wikimedia.org/pywikibugs account to let it know that it's PAT named "read-only" would expire on 2025-05-11. I guess this means that the attempt to remove expiration from all tokens set to expire in 2025 didn't completely work. For this particular instance I just issued a new non-expiring token and rotated the credentials for the bot to use it. I have left the other token attached to the account, so we could try to use that to verify another attempt at removing expiry if folks are interested in trying that.

Same thing for gitlab-exporter, we got a 60 day expiry notification yesterday.

Same thing for gitlab-exporter, we got a 60 day expiry notification yesterday.

I double checked the gitlab-exporter token and it also had a expiration date. So I rotated the token and added a small description here https://wikitech.wikimedia.org/wiki/GitLab/Monitoring#Custom_exporter. The new token has no expiry date anymore.