FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Issue with bcrypt on import of users

    Scheduled Pinned Locked Moved
    Q&A
    bcrypt password hashed password
    0
    2
    1.2k
    Loading More Posts
    • 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.
    • danD
      dan
      last edited by

      The Bcrypt passwords have stored salt in their own hash, yet imported users get unexpected error when trying to log in. There is "Bad salt length" error in the FA logs.

      I am using 1.25.

      Steps to reproduce the behavior:

      • Create Bcrypt hashed password (you can use online bcrypt generators) using 4 rounds
      • Make request to Fusion Auth Import API with JSON like:
      { "users": [ { "username": "username", "active": true, "password": "generatedhash", "salt": "", "encryptionScheme": "bcrypt", "email": "test@gmail.com", "factor": 4, "verified": true, "registrations": [ { "applicationId": "id" } ] } ] }
      
      • Import succeeds with status 200
      • Try to login with imported user into the application
      • Receive unexpected error when trying to login(only with this user). Logs say "bad salt length". User is visible via FA admin, after changing his password via the dashboard his login works

      --
      FusionAuth - Auth for devs, built by devs.
      https://fusionauth.io

      1 Reply Last reply Reply Quote 0
      • danD
        dan
        last edited by

        You'll need to separate out the hash and the salt on the Import API.

        For example, the hash $2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy would be split out to the fields:

        factor: 10
        salt: N9qo8uLOickgx2ZMRZoMye
        password: IjZAgcfl7p92ldGxad68LJZdL17lhWy

        The Import API does not parse this value and separate it out for you. You need to do so.

        Here is an example import script (in Ruby): https://github.com/FusionAuth/fusionauth-import-scripts/blob/master/auth0/import.rb#L47

        --
        FusionAuth - Auth for devs, built by devs.
        https://fusionauth.io

        1 Reply Last reply Reply Quote 0
        • First post
          Last post