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. Feature Requests
  3. Change Add User API

Change Add User API

Scheduled Pinned Locked Moved Feature Requests
api
24 Posts 6 Posters 2.7k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M michaelpope

    @plusone-nick Hey Plusone, sorry if I'm just jumping in, have you thought about setting the password to a random value server side and then sending them a change password link? Not sure if that would help much at all though.

    Hope you are having an awesome day.

    P Offline
    P Offline
    plusone-nick
    wrote on last edited by
    #14

    @michaelpope no worries at all and thanks for chiming in. That is doable, similar to making the new user not active upon creation when my form calls the api, coupled with setting a random password….πŸ€” sounds like it would work

    I will have to test how this workflow would impact the send invite email as the last step

    βœŒπŸ’™+1

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

      For some reason I am still not seeing the issue you are facing and which issue arose from using the rest api. Instead of creating a random password, you may just not provide a password at all? You can see at https://docs.cloudron.io/api.html#tag/Users/paths/~1users/post that only the email is strictly required.

      P 1 Reply Last reply
      2
      • nebulonN nebulon

        For some reason I am still not seeing the issue you are facing and which issue arose from using the rest api. Instead of creating a random password, you may just not provide a password at all? You can see at https://docs.cloudron.io/api.html#tag/Users/paths/~1users/post that only the email is strictly required.

        P Offline
        P Offline
        plusone-nick
        wrote on last edited by plusone-nick
        #16

        @nebulon not a problem, we will get to the bottom of this eventually

        I have already removed the password field from the form and API call...the issue is that the add user API will still accept the full schema without using my form (via an API tool like postman not on my form) Thus someone can simply obtain my API endpoint then inject a password with the rest of the body and then just log in...

        I have implemented and am testing the "de-activate" and "random password" workaround's but to be honest this is not an ideal solution

        βœŒπŸ’™+1

        MooCloud_MattM 1 Reply Last reply
        0
        • P plusone-nick

          @nebulon not a problem, we will get to the bottom of this eventually

          I have already removed the password field from the form and API call...the issue is that the add user API will still accept the full schema without using my form (via an API tool like postman not on my form) Thus someone can simply obtain my API endpoint then inject a password with the rest of the body and then just log in...

          I have implemented and am testing the "de-activate" and "random password" workaround's but to be honest this is not an ideal solution

          MooCloud_MattM Offline
          MooCloud_MattM Offline
          MooCloud_Matt
          wrote on last edited by
          #17

          @plusone-nick
          Just to understand better, you want to use have a public form that comunicare to Cloudron api directly?

          Matteo. R.
          Founder and Tech-Support Manager.
          MooCloud MSP
          Swiss Managed Service Provider

          P 1 Reply Last reply
          0
          • MooCloud_MattM MooCloud_Matt

            @plusone-nick
            Just to understand better, you want to use have a public form that comunicare to Cloudron api directly?

            P Offline
            P Offline
            plusone-nick
            wrote on last edited by
            #18

            @MooCloud_Matt yes, my form/API call Cloudron Add User API

            βœŒπŸ’™+1

            MooCloud_MattM 1 Reply Last reply
            0
            • P plusone-nick

              @MooCloud_Matt yes, my form/API call Cloudron Add User API

              MooCloud_MattM Offline
              MooCloud_MattM Offline
              MooCloud_Matt
              wrote on last edited by MooCloud_Matt
              #19

              @plusone-nick
              I would not do that, with that key saved in your front end code, anybody can access your server with not need of a password.
              And see all your data, stealing what you have save in it.

              You need to build a server route, that get the information from the from and create your user in Cloudron.

              Matteo. R.
              Founder and Tech-Support Manager.
              MooCloud MSP
              Swiss Managed Service Provider

              nebulonN P 2 Replies Last reply
              0
              • MooCloud_MattM MooCloud_Matt

                @plusone-nick
                I would not do that, with that key saved in your front end code, anybody can access your server with not need of a password.
                And see all your data, stealing what you have save in it.

                You need to build a server route, that get the information from the from and create your user in Cloudron.

                nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #20

                @MooCloud_Matt that makes sense now, I didn't expect that the access token was part of the frontend assets!

                P 1 Reply Last reply
                1
                • MooCloud_MattM MooCloud_Matt

                  @plusone-nick
                  I would not do that, with that key saved in your front end code, anybody can access your server with not need of a password.
                  And see all your data, stealing what you have save in it.

                  You need to build a server route, that get the information from the from and create your user in Cloudron.

                  P Offline
                  P Offline
                  plusone-nick
                  wrote on last edited by plusone-nick
                  #21

                  @MooCloud_Matt my Cloudron api token is not exposed to the front-end it is server side and is not passed when invoked.
                  Edit- Maybe I should have stated it as: my form calls and passes post data to my api and then my api handles the data and calls the cloudron api.

                      "name": "set_cloudron_reg_url",
                      "module": "core",
                      "action": "setvalue",
                      "options": {
                        "value": "{{$_ENV.cloudron_api_url}}users{{$_ENV.cloudron_api_token}}",
                        "key": "test_global"
                  

                  you're more than welcome to look at the code here: https://git.plusone.network/nick/cloudron-registration-community/-/blob/master/dmxConnect/api/new_user_flow.php

                  βœŒπŸ’™+1

                  1 Reply Last reply
                  0
                  • nebulonN nebulon

                    @MooCloud_Matt that makes sense now, I didn't expect that the access token was part of the frontend assets!

                    P Offline
                    P Offline
                    plusone-nick
                    wrote on last edited by plusone-nick
                    #22

                    @nebulon
                    Here is my workflow: There are only two API calls and three set vars.
                    ENV_vars are NOT hardcoded or passed client side.

                    • SET - Dynamically generate a Cloudron URL including TOKEN to add a new user
                    • API - Cloudron api call that includes JSON data from the form input (not including the password field on purpose)

                    On success of add user:

                    • SET - Capture user ID to send an invite link
                    • SET - a dynamic URL which will be used to send the newly created user an Invite email. Use the userid_for_group var
                    • API - Send the new user an invite email using the dynamic URL (api1_user_id) var & the ($_POST.email) var

                    Is this wrong? or im missing something....?

                    IMO the issue resides in the Add User API schema

                    EDIT - Ideal solution seems to be removing the password field from the add user API schema thus requiring the user to set the password via the invite email and since its originally not required I am assuming it would not negatively impact Cloudron's core code....but you'd have to verify that

                    Lastly, I am still testing the active/set random password workaround

                    βœŒπŸ’™+1

                    P MooCloud_MattM 2 Replies Last reply
                    0
                    • P plusone-nick

                      @nebulon
                      Here is my workflow: There are only two API calls and three set vars.
                      ENV_vars are NOT hardcoded or passed client side.

                      • SET - Dynamically generate a Cloudron URL including TOKEN to add a new user
                      • API - Cloudron api call that includes JSON data from the form input (not including the password field on purpose)

                      On success of add user:

                      • SET - Capture user ID to send an invite link
                      • SET - a dynamic URL which will be used to send the newly created user an Invite email. Use the userid_for_group var
                      • API - Send the new user an invite email using the dynamic URL (api1_user_id) var & the ($_POST.email) var

                      Is this wrong? or im missing something....?

                      IMO the issue resides in the Add User API schema

                      EDIT - Ideal solution seems to be removing the password field from the add user API schema thus requiring the user to set the password via the invite email and since its originally not required I am assuming it would not negatively impact Cloudron's core code....but you'd have to verify that

                      Lastly, I am still testing the active/set random password workaround

                      P Offline
                      P Offline
                      plusone-nick
                      wrote on last edited by plusone-nick
                      #23

                      Update: Random password solution appears to work....
                      πŸ™ Thanks @michaelpope +1 for the suggestion πŸ‘

                      • setting the new user to inactive ended up being a labyrinth that I am not trying to entertain πŸ˜ͺ

                      TLDR:

                      The "CATCH 22" is: Without setting a RANDOM password call AFTER a newly created user will result in an attack vector via the add user API - In practice: the "password" field can be injected in the body, passing the form.

                      Testing further πŸ€™

                      βœŒπŸ’™+1

                      1 Reply Last reply
                      1
                      • P plusone-nick

                        @nebulon
                        Here is my workflow: There are only two API calls and three set vars.
                        ENV_vars are NOT hardcoded or passed client side.

                        • SET - Dynamically generate a Cloudron URL including TOKEN to add a new user
                        • API - Cloudron api call that includes JSON data from the form input (not including the password field on purpose)

                        On success of add user:

                        • SET - Capture user ID to send an invite link
                        • SET - a dynamic URL which will be used to send the newly created user an Invite email. Use the userid_for_group var
                        • API - Send the new user an invite email using the dynamic URL (api1_user_id) var & the ($_POST.email) var

                        Is this wrong? or im missing something....?

                        IMO the issue resides in the Add User API schema

                        EDIT - Ideal solution seems to be removing the password field from the add user API schema thus requiring the user to set the password via the invite email and since its originally not required I am assuming it would not negatively impact Cloudron's core code....but you'd have to verify that

                        Lastly, I am still testing the active/set random password workaround

                        MooCloud_MattM Offline
                        MooCloud_MattM Offline
                        MooCloud_Matt
                        wrote on last edited by MooCloud_Matt
                        #24

                        @plusone-nick
                        I didn't check the part of our code that manage user creation for ages, but 99% sure, that you don't need to provide a password, or not even a username just an email.

                        Then you create the invite link with a second request if you want to have the onboarding process managed by cloudron.

                        Personal note:
                        Remember that as the server owner you are responsible for the content hosted in it, for this is normally a good idea to have some manual approval before creating an account from a form; or you have to provide a good moderation.

                        Matteo. R.
                        Founder and Tech-Support Manager.
                        MooCloud MSP
                        Swiss Managed Service Provider

                        1 Reply Last reply
                        0
                        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