reposilite icon indicating copy to clipboard operation
reposilite copied to clipboard

Add parameter and local config option to import tokens

Open einsibjarni opened this issue 2 years ago • 4 comments

Request details

Using automation to deploy reposilite now is hampered by the fact that persistent tokens can only be created through the cli.

I like to write an ansible playbook that deploys services, and when there are changes, I update the playbook and re-run it.

As it stands, the only way to do that with reposilite is to add --token to command line, so it always starts up with the same temporary token (parameter shows up in process list, unless I further obfuscate with env variable) or using expect (complicated, ansible would have to shut down the service, run the service interactively and then use expect to run the token-import command)

I wish I could use ansible to generate tokens.json and then add a parameter or config option to always have reposilite flush it's tokens and import from the file

einsibjarni avatar Aug 31 '23 10:08 einsibjarni

As a workaround you can POST to the integrated Console like this:

curl -X POST http://localhost:8080/api/console/execute \
     -H "Content-Type: application/x-www-form-urlencoded" \
     -H "Authorization: Basic $(echo -n admin:secret | base64)" \
     -d "token-import tokens.json"

It works as if you entered the command manually:

{"status":"SUCCEEDED","response":["Importing 2 token(s) from [...]/tokens.json file:",
  "Access token 'abc' has been imported.","Access token 'xyz' has been imported."]}j

jan-z avatar Dec 28 '24 14:12 jan-z

Except I'll need the cli to create the initial token, which I could then use with the API.

Unless I'm misunderstanding?

einsibjarni avatar Feb 12 '25 15:02 einsibjarni

@einsibjarni the initial token can be created via --token parameter:

  • https://reposilite.com/guide/general#parameters

E.g.:

--token einsibjarni:password

dzikoysk avatar Feb 12 '25 20:02 dzikoysk

In https://reposilite.com/guide/kubernetes#creating-the-first-access-token and https://reposilite.com/guide/tokens#generating-token token-generate is mentioned but does not work.

Yes, you can work around by adding

  - name: REPOSILITE_OPTS
    value: '--token admin:secret'

as parameter but changing that token afterwards is difficult

cbr46 avatar May 22 '25 11:05 cbr46