Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions authorize_request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import (
"strings"

"github.com/go-jose/go-jose/v3"
"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
"go.opentelemetry.io/otel/trace"

"github.com/ory/fosite/i18n"
"github.com/ory/fosite/token/jwt"
"github.com/ory/go-convenience/stringslice"
"github.com/ory/x/errorsx"
"github.com/ory/x/otelx"

"github.com/pkg/errors"

"github.com/ory/go-convenience/stringslice"
)

func wrapSigningKeyFailure(outer *RFC6749Error, inner error) *RFC6749Error {
Expand Down Expand Up @@ -66,11 +65,16 @@ func (f *Fosite) authorizeRequestParametersFromOpenIDConnectRequest(ctx context.
}

hc := f.Config.GetHTTPClient(ctx)
response, err := hc.Get(location)
req, err := retryablehttp.NewRequestWithContext(ctx, "GET", location, nil)
if err != nil {
return errorsx.WithStack(ErrInvalidRequestURI.WithHintf("Unable to fetch OpenID Connect request parameters from 'request_uri' because: %s.", err.Error()).WithWrap(err).WithDebug(err.Error()))
}
response, err := hc.Do(req)
if err != nil {
return errorsx.WithStack(ErrInvalidRequestURI.WithHintf("Unable to fetch OpenID Connect request parameters from 'request_uri' because: %s.", err.Error()).WithWrap(err).WithDebug(err.Error()))
}
defer response.Body.Close()
response.Body = io.NopCloser(io.LimitReader(response.Body, 10*1024*1024)) // limit to 10MiB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the limit be configurable? You could make it a config property in Fosite struct itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary. This is a defence mechanism only. Do you think 10MiB is too small?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say, particularly with RAR. I don't see any reason why it shouldn't be parameterized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any reason why it shouldn't be parameterized.

The reason is that it's more complicated (more code).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be controlled by the OP using Fosite. Perhaps just a property in the struct? It doesn't have to be a full blown Configurator...


if response.StatusCode != http.StatusOK {
return errorsx.WithStack(ErrInvalidRequestURI.WithHintf("Unable to fetch OpenID Connect request parameters from 'request_uri' because status code '%d' was expected, but got '%d'.", http.StatusOK, response.StatusCode))
Expand Down
Loading