ciur / papermerge

Open Source Document Management System for Digital Archives (Scanned Documents)
https://papermerge.com
Apache License 2.0
2.49k stars 263 forks source link

Generated api token not valid after some hours #593

Open smart-clouds-09 opened 8 months ago

smart-clouds-09 commented 8 months ago

The tokens, which are generated with create_token.sh are not valid anymore after a time, in my case some hours. I have been using the token for papermerge-cli to import docs. After a time papermerge-cli throws :

/usr/local/lib/python3.10/site-packages/pydantic/_migration.py:283: UserWarning: pydantic.generics:GenericModel has been moved to pydantic.BaseModel. warnings.warn(f'{import_path} has been moved to {new_location}.') Unauthorized

Is a new token generated, it works for a while

Info:

ciur commented 7 months ago

Default expiration time for the token is 360 minutes (i.e. 6 hours). If you want to change that use PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES settings. I forgot to add that to docs. I will mark this ticket as documentation issue and update documentation accordingly.

smart-clouds-09 commented 7 months ago

thanks, is there a value for unexpired ?

ciur commented 7 months ago

I've updated documentation.

Is there a value for unexpired

No. Just set it to big enough value. E.g. 525600 (60x24x365) is the number of minutes in a year.

smart-clouds-09 commented 7 months ago

meanwhile I have written a script, which updates the token after a few minutes. Thank for updating the docs

WolfgangFahl commented 1 month ago

Please reopen the issue and change the default to at least 1 year. https://docs.papermerge.io/3.0/rest-api/token/ is also hard to find - this should be part of describing the API

WolfgangFahl commented 1 month ago

thx i am using

# Token expiration time in minutes. Here, it's set to 2 years (1051200 minutes).
# Adjust as necessary for your security requirements.
PAPERMERGE__SECURITY__TOKEN_EXPIRE_MINUTES=1051200

as a workaround in the papermerge script at https://github.com/WolfgangFahl/scan2wiki/blob/main/scripts/papermerge

see also https://wiki.bitplan.com/index.php/Papermerge#Exploring_the_environment_variables