Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache the access token in the system environement #6

Open
PietrH opened this issue Nov 10, 2023 · 9 comments
Open

cache the access token in the system environement #6

PietrH opened this issue Nov 10, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@PietrH
Copy link
Member

PietrH commented Nov 10, 2023

Maybe store the access token for a bit, similar to etn and rgbif

@PietrH PietrH added the enhancement New feature or request label Nov 10, 2023
@PietrH PietrH self-assigned this Nov 10, 2023
@PietrH
Copy link
Member Author

PietrH commented Nov 13, 2023

We could also store the login credentials as a system variable (hashed i suppose!), as this is what rgbif actually does in the backend. Then we could keep calling get_access_token() as a helper in functions without the need to keep prompting the user all the time.

What do you think @SanderDevisscher ?

  • Store the access token itself locally
  • Store the access credentials locally

On second thought, the access token itself is probably safer, in case users reuse their password somewhere.

Ideally we'd want to use something like keyring for the authentication credentials. Something for the future perhaps.

@SanderDevisscher
Copy link
Collaborator

SanderDevisscher commented Nov 13, 2023

I have no clear preference. I personally would go with the easiest method to use/implement for now and look into more secure options in the future.

@PietrH
Copy link
Member Author

PietrH commented Nov 14, 2023

I have checked if access tokes eventually get invalidated on the iAsset side without a request to do so (logout api post request), and it seems this is indeed the case.

So you can't just keep using the same access token forever, good.

@SanderDevisscher
Copy link
Collaborator

related but not a fix is to add password as a function parameter of get_access_token this allows for storing your password in the .renviron file just like rgbif. Unless you think this is a bad idea.

@PietrH
Copy link
Member Author

PietrH commented Nov 14, 2023

I think we're best off caching the access_token itself, rather than the password. This will mean that users will probably need to login once in a while, which is not a bad thing. We can write get_access_token() to check for a local cached token, to try it, and if it doesn't work, to try to regenerate one prompting the user for a username and password.

@PietrH PietrH added this to the Get a tibble out! milestone Nov 14, 2023
@SanderDevisscher
Copy link
Collaborator

1 question though I'm looking into automating retrieval of vespawatch nests using github actions and I was just wondering if this will work if we cache the token instead of being able to provide a password as environment variable.

@PietrH
Copy link
Member Author

PietrH commented Nov 16, 2023

1 question though I'm looking into automating retrieval of vespawatch nests using github actions and I was just wondering if this will work if we cache the token instead of being able to provide a password as environment variable.

This is an important design decision to keep in mind, can you make an issue for further discussion?

If we retrieve personal information via the API, we might need to make sure no data is stored unencrypted on the runner or in artefacts, and we might be obliged to process data in the EU only. I'm not sure on the specifics but we need to thread lightly. We are capable of using our own custom runners via AWS in a EU region, but it'll take a bit of doing and have a slight cost.

@PietrH
Copy link
Member Author

PietrH commented Dec 13, 2023

I think we should probably allow passing the credentials as environmental variables. With this in mind I still think it could be useful to cache the token for a bit.

It's unclear how long a token remains valid. Any ideas? I'll send an email to support

@PietrH PietrH modified the milestones: Get a tibble out! , v0.1 Dec 13, 2023
@PietrH
Copy link
Member Author

PietrH commented Dec 13, 2023

System tokens are valid for 24h

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants