Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Translate
  3. Lock libretranslate to only users with api keys

Lock libretranslate to only users with api keys

Scheduled Pinned Locked Moved Translate
13 Posts 3 Posters 653 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic was forked from How to create API key? joseph
This topic has been deleted. Only users with topic management privileges can see it.
  • visampV Offline
    visampV Offline
    visamp
    wrote on last edited by
    #1

    If I install a key, do I need to comment out the line below so that it is locked down to only users with api keys?

    image.png

    1 Reply Last reply
    1
    • visampV Offline
      visampV Offline
      visamp
      wrote on last edited by
      #2

      When tried to setup the keys, as well, I ended up creating four, which is probably fine. But, I ran this command to try to remove the three extra keys for simplicity sake and failed. How do I amend this code to remove keys:

      su - cloudron -c 'source /app/code/.venv/bin/activate; ltmanage keys remove <key-I-want-to-remove> --api-keys-db-path /app/data/db/api_keys.db'

      The documentation from libretranslate really doesn't help all that much because of how Cloudron interacts with things. Please let me know where I went wrong with my attempt at hacking the code together above because it didn't work.

      1 Reply Last reply
      0
      • visampV Offline
        visampV Offline
        visamp
        wrote on last edited by
        #3

        I used this code successfully to show my keys - maybe want to update the docs to show this code as the link to the libretranslate docs shows code that doesn't have the Cloudron layered on:

        su - cloudron -c 'source /app/code/.venv/bin/activate; ltmanage keys --api-keys-db-path /app/data/db/api_keys.db'

        Also, in the main dashboard of the app, this link is broken (misspelled https://)

        2025-03-12_12-22.png

        1 Reply Last reply
        0
        • visampV Offline
          visampV Offline
          visamp
          wrote on last edited by
          #4

          So, basically, these codes work:

          Add a new key:

          su - cloudron -c 'source /app/code/.venv/bin/activate; ltmanage keys --api-keys-db-path /app/data/db/api_keys.db add 120'

          Show all created keys:
          su - cloudron -c 'source /app/code/.venv/bin/activate; ltmanage keys --api-keys-db-path /app/data/db/api_keys.db'

          But, the remove key doesn't seem to work for me (I don't understand the formatting) and it would be great to have a character set version as well such as from LibreTranslate: ltmanage keys add 120 --char-limit 5000

          Okay, sorry for the rapid fire.

          1 Reply Last reply
          2
          • nebulonN Offline
            nebulonN Offline
            nebulon
            Staff
            wrote on last edited by
            #5

            @visamp thanks for the hint about the wrong URL, this is fixed now for next package release.

            We will further add the key listing docs then.

            1 Reply Last reply
            2
            • visampV Offline
              visampV Offline
              visamp
              wrote on last edited by visamp
              #6

              Thank you! Do you know off hand what the code would be to remove a certain API key?

              1 Reply Last reply
              0
              • nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #7

                We have also added listing and removing keys commands in the docs page now at https://docs.cloudron.io/apps/libretranslate/#api

                1 Reply Last reply
                2
                • visampV Offline
                  visampV Offline
                  visamp
                  wrote on last edited by
                  #8

                  Rock on! This is perfect and super helpful.

                  1 Reply Last reply
                  2
                  • visampV Offline
                    visampV Offline
                    visamp
                    wrote on last edited by
                    #9

                    Do you know if I install a key, do I need to comment out the line below so that it is locked down to only users with api keys?

                    0ca09fba-1e20-4f33-a4f7-59458b37370e-image-resized.png

                    1 Reply Last reply
                    0
                    • nebulonN Offline
                      nebulonN Offline
                      nebulon
                      Staff
                      wrote on last edited by nebulon
                      #10

                      From the README it seems Set maximum number of requests per minute per client (outside of limits set by api keys) so maybe yes. But not really sure. Maybe you can ask upstream about this.

                      Also below LT_REQUIRE_API_KEY_ORIGIN is set to true, maybe that means the instance is already locked down to only api keys, but also this is not totally clear to me.

                      1 Reply Last reply
                      2
                      • visampV Offline
                        visampV Offline
                        visamp
                        wrote on last edited by
                        #11

                        According to folks on their forum, there's another step to lock down:

                        https://community.libretranslate.com/t/locking-down-api-key-on-self-hosted-through-cloudron/1767/2

                        We may need to update the docs here on cloudron:

                        To configure requirement for api key to use, set --req-limit to 0 and add the --api-keys flag. Requests made without a proper api key will be rejected.

                        1 Reply Last reply
                        2
                        • M Offline
                          M Offline
                          mononym
                          wrote on last edited by
                          #12

                          Hello. When I run the su - cloudron -c 'source /app/code/.venv/bin/activate; ltmanage keys --api-keys-db-path /app/data/db/api_keys.db add 120' command from the docs, I get This account is currently not available. Was there an update of the API ?

                          1 Reply Last reply
                          0
                          • nebulonN Offline
                            nebulonN Offline
                            nebulon
                            Staff
                            wrote on last edited by
                            #13

                            Looks like the correct way to call ltmanage now (probably related to the base image python update), is to first source the pyhton env and then run the command:

                            source /app/code/venv/bin/activate
                            ltmanage keys --api-keys-db-path /app/data/db/api_keys.db
                            
                            1 Reply Last reply
                            1
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Bookmarks
                            • Search