Skip to content

rp.AuthURLHandler state function should accept http.Request #838

@CharlesPhilippeLabbe

Description

@CharlesPhilippeLabbe

Preflight Checklist

  • I could not find a solution in the existing issues, docs, nor discussions
  • I have joined the ZITADEL chat

Describe your problem

Its hard to embed the "state of the user in [our] application" when the state function callback has no parameters.
Right now we are forced to do something like that (which is impractical and defeats the purpose of having AuthURLHandler at all)

	e.GET("/login", func(ctx echo.Context) error {

		state := func() string {
			return encodeState(&State{
				Id: uuid.New().String(), 
				redirect: ctx.Request().URL.String(),
			})
		}
		loginHandler := rp.AuthURLHandler( state, provider, urlOptions...)
		loginHandler.ServeHTTP(ctx.Response(), ctx.Request())
		return nil
	})

Describe your ideal solution

Now, as a user i'd prefer receiving the Request directly from the state callback, which would be a lot more useful.

	state := func(req http.Request) string {
		return encodeState(&State{
			Id: uuid.New().String(), 
			redirect: req.URL.String(),
		})
	}
	e.GET("/login", echo.WrapHander(rp.AuthURLHandler( state, provider, urlOptions...))
 

Now, granted to maintain backwards compatibility you'd have to create a new function with a new name.

Version

HEAD

Environment

Self-hosted

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions