Gitlab enforced token expiry limits to 365 days last year, and the time is now upon us.
They don't have an opt-out for this, and haven't provided a way to easily extend tokens in the web interface. They have also gated their credential management interface behind their Ultimate license.
This quickly thrown together script will allow you to add an extra year to all tokens that expire in the next 30 days. It will not reactivate tokens that have already expired.
Requires the python-gitlab module. Edit your self-hosted Gitlab instance details into the script and run it. It will dump out CSVs of all expiring tokens, and then dump out a list of commands you can paste into a gitlab-rails console
session to extend the expiry date by another year. If you need them to be active for longer, change 1.year.from_now
to the value of your choice, e.g. 10.years.from_now
.
Rotating your tokens is the right thing to do, but sometimes you just need more time.
what about using "
last_used_at
" attribute :