Coder Social home page Coder Social logo

Error response doesn't follow spec about fosite HOT 3 CLOSED

ory avatar ory commented on April 28, 2024
Error response doesn't follow spec

from fosite.

Comments (3)

aeneasr avatar aeneasr commented on April 28, 2024

Nice catch :) But you can be sure that all of AuthorizeRequest's parameters are already validated. This for example is covered here and more specifically here.

But due to your inquiry I found another issue where in fact the AuthorizeRequest will be nil if an error occurs in NewAuthorizeRequest and fosite will most likely panic in WriteAuthError due to a nil pointer. Looks like NewAuthorizeRequest must always return a non-nil value for AuthorizeRequest

from fosite.

danielchatfield avatar danielchatfield commented on April 28, 2024

They are validated but then that method returns an error which as per the README is passed to WriteAuthorizeError which then uses the redirect_uri despite it potentially being the reason why validation failed.

authorizeRequest, err := oauth2.NewAuthorizeRequest(ctx, r)
    if err != nil {
       oauth2.WriteAuthorizeError(rw, req, err)
       return
    }

from fosite.

aeneasr avatar aeneasr commented on April 28, 2024

Ha! Got it, nice catch!

This should do, right? ErrInvalidRequest is thrown when the redirect uri is invalid:

    if ar.GetRedirectURI().String() == "" || err == ErrInvalidRequest {
        pkg.WriteJSON(rw, rfcerr)
        return
    }

It might be smarter and more transparent making validation explicit:

    if !ar.HasValidRedirectURL() {
        pkg.WriteJSON(rw, rfcerr)
        return
    }

As promised, check the Hall of Fame

from fosite.

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.