jon-lipstate / opm_cli

MIT License
5 stars 3 forks source link

Cross-platform opm token solution #2

Open hrszpuk opened 10 months ago

hrszpuk commented 10 months ago

Problem

Extract from README.md:

Storing auth token via opm token is Linux-Only at present. 
The token is stored as an environment variable OPM_TOKEN. 
This can be manually set for Windows and Darwin. (FIXME)

Proposed Solution: Encrypted Token File

Instead of storing the OPM_TOKEN as an environmental variable, why not use a config file? Storing the token in a file would simplify the token code significantly as file I/O is cross-platform using core:os. In addition, the token file could be encrypted to add additional security for the users of opm_cli.

Config locations

Here are examples of config locations that would be platform dependent. All these paths include an "opm_cli" folder for any files/data the package manager may need to store in the future.

Additional features

Since an environmental variable allows users to see their token when typed into a terminal, I'm also going to suggest we expand the opm token subcommand to the following subcommands:

opm token                <--- Displays help menu (perhaps specific to `opm token`?)
opm token show           <--- Displays the token stored in the config (password needed to decrypt)
opm token set [TOKEN]    <--- Sets the token file contents to the value provided (password needed to encrypt)
opm token delete         <--- Sets the token file contents to an empty string
opm token find           <--- Displays the token file location (+ checks it exists)
hrszpuk commented 10 months ago

I don't mind working on this, but I would prefer if you give the go ahead (+ anything you want to add/change) so I know this isn't something you don't want and my work goes to waste 😅.

hrszpuk commented 10 months ago

Alright since I got a response on Discord I'll start implementing it.