Giter Site home page Giter Site logo

Comments (6)

rburgst avatar rburgst commented on August 26, 2024

For http BASIC auth this is trivial. For digest it's IMHO not so easy since usually the digest is a handshake between server and client where both parties trade nonces. AFAIR there is a way to do that but it would probably require a lot of new code that doesn't exist in okhttp-digest.

from okhttp-digest.

skogl avatar skogl commented on August 26, 2024

Thanks for the reply!

I suspected this was the case. Maybe I can do some other intercept trick in okhttp to "fix" it? Say for instance that if my "require authentication" flag is set I check to see if the authentication header is present in the response and if it's not I simply throw exception/break chain. That way anonymous requests only work when authentication flag is not set.

What do you think of such solution?

from okhttp-digest.

rburgst avatar rburgst commented on August 26, 2024

To get preemptive HTTP Basic Authentication you can simply add the basic auth header yourself: https://stackoverflow.com/a/57360804/464773.

Alternatively you can use the https://github.com/rburgst/okhttp-digest/blob/master/src/main/java/com/burgstaller/okhttp/AuthenticationCacheInterceptor.java and pre-inject the HTTP Basic Authentication.

As said earlier, this wont work for digest as currently there is no way to pre-authenticate digest authentication.

The only thing that you could do for digest auth is to make a first request directly to a server endpoint that produces a 401.

from okhttp-digest.

skogl avatar skogl commented on August 26, 2024

Yes, thank you. Before using this package I was adding my own interceptor for basic authentication. The issue I'm having is when a server can handle both anonymous and logged in content and I want to force the logged in content.

I understand what you are saying. I will do some more tests before dropping this entirely.

from okhttp-digest.

skogl avatar skogl commented on August 26, 2024

Is this issue Fixed or just Closed (Completed)?

from okhttp-digest.

rburgst avatar rburgst commented on August 26, 2024

As I didn't get any more feedback I closed this ticket.

from okhttp-digest.

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.