Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing a Basic Authorization header fails if password contains ':' #3193

Open
camarena opened this issue Oct 23, 2024 · 4 comments · May be fixed by #3201
Open

Parsing a Basic Authorization header fails if password contains ':' #3193

camarena opened this issue Oct 23, 2024 · 4 comments · May be fixed by #3201
Labels
💎 Bounty bug Something isn't working

Comments

@camarena
Copy link

The method zio.http.Header.Authorization.parseBasic fails with Basic Authorization header value is not in the format username:password if the password contains a ':'. partsOfBasic.length will be greater than 2 in that case.

    private def parseBasic(value: String): Either[String, Authorization] = {
      try {
        val partsOfBasic = new String(Base64.getDecoder.decode(value)).split(":")
        if (partsOfBasic.length == 2) {
          Right(Basic(partsOfBasic(0), Secret(partsOfBasic(1))))
        } else {
          Left("Basic Authorization header value is not in the format username:password")
        }
      } catch {
        case _: IllegalArgumentException =>
          Left("Basic Authorization header value is not a valid base64 encoded string")
      }
    }

@jdegoes
Copy link
Member

jdegoes commented Nov 9, 2024

/bounty $75 for fix and tests.

Copy link

algora-pbc bot commented Nov 9, 2024

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3193 with your implementation plan
  2. Submit work: Create a pull request including /claim #3193 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio-http!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @mobley-trent Nov 9, 2024, 8:51:06 AM #3201

@mobley-trent
Copy link

mobley-trent commented Nov 9, 2024

/attempt #3193

Algora profile Completed bounties Tech Active attempts Options
@mobley-trent    1 ZIO bounty
+ 10 bounties from 4 projects
Python, Rust,
Go & more
Cancel attempt

@mobley-trent mobley-trent linked a pull request Nov 9, 2024 that will close this issue
Copy link

algora-pbc bot commented Nov 9, 2024

💡 @mobley-trent submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💎 Bounty bug Something isn't working
Projects
None yet
3 participants