Coder Social home page Coder Social logo

Parsing Authorization fails about polyglot HOT 9 CLOSED

abnair24 avatar abnair24 commented on June 30, 2024
Parsing Authorization fails

from polyglot.

Comments (9)

dinowernli avatar dinowernli commented on June 30, 2024

We should definitely fix polyglot to ignore the trailing space.

As a workaround, can you pass the argument without a space in the meanwhile?

from polyglot.

abnair24 avatar abnair24 commented on June 30, 2024

@dinowernli If i pass argument without space ,server returns as authorization failure

from polyglot.

dinowernli avatar dinowernli commented on June 30, 2024

A few questions from my side:

  • Is there any chance you could add your exact invocation of polyglot and the output you are seeing? That would make it easier to narrow down the issue.
  • Your use case for passing a metadata value with a trailing space seems to be to pass an empty bearer token. Just curious, how come you need to do that? Is the recipient distinguishing the case of an empty bearer from the case of not passing any authorization header at all?

from polyglot.

jchoffmann avatar jchoffmann commented on June 30, 2024

I have the same problem, metadata key/value pairs that contain spaces fail to parse, which renders basic auth impossible. Example invocation:

java -jar polyglot.jar --command=call --proto_discovery_root=<proto dir> --endpoint=<server> --metadata=Authorization:"Basic xyz" --full_method='<method>' <<< '<payload>'

yields

[main] INFO me.dinowernli.grpc.polyglot.Main - Polyglot version: 1.6.0
Exception in thread "main" java.lang.RuntimeException: Unable to parse command line flags
at me.dinowernli.grpc.polyglot.Main.main(Main.java:33)
Caused by: java.lang.IllegalArgumentException: Unable to parse command line flags
at me.dinowernli.grpc.polyglot.config.CommandLineArgs.parse(CommandLineArgs.java:120)
at me.dinowernli.grpc.polyglot.Main.main(Main.java:31)
Caused by: org.kohsuke.args4j.CmdLineException: "--metadata=Authorization:Basic xyz" is not a valid option
at org.kohsuke.args4j.CmdLineParser.parseArgument(CmdLineParser.java:512)
at me.dinowernli.grpc.polyglot.config.CommandLineArgs.parse(CommandLineArgs.java:118)
... 1 more

Other combinations of single quotes / double quotes around the value only as well as both key-value pair had the same result.

Removing the space passes parsing but then obviously fails service authentication.

from polyglot.

dinowernli avatar dinowernli commented on June 30, 2024

I looked into the issue and it appears to be a problem with args4j. I have long-standing plans to switch to something like jCommander or flagz, which should fix this.

Don't really have an ETA yet for when I'll get around to switching things over though.

from polyglot.

jchoffmann avatar jchoffmann commented on June 30, 2024

I already had a quick look and could provide a first PR soon if you're OK with that.

from polyglot.

dinowernli avatar dinowernli commented on June 30, 2024

@jchoffmann sounds great if you're up for it. Happy to stare at an early draft of a PR as well if that helps.

from polyglot.

jchoffmann avatar jchoffmann commented on June 30, 2024

@dinowernli Sure, first version is done and all tests are passing. Just need to do some cleaning up and will create the PR shortly.

from polyglot.

dinowernli avatar dinowernli commented on June 30, 2024

This is now fixed at head since #108.

from polyglot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.