Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client api Whoami not work with Header Authorization #1215

Closed
und3fined opened this issue Apr 8, 2021 · 4 comments · Fixed by #1244
Closed

client api Whoami not work with Header Authorization #1215

und3fined opened this issue Apr 8, 2021 · 4 comments · Fixed by #1244

Comments

@und3fined
Copy link

Hi team,

Whoami not support query authorization, but code generate with query.
No any Header Authorization is set

Bug in here

Please hotfix it thanks.

@aeneasr
Copy link
Member

aeneasr commented Apr 8, 2021

Thank you for contributing to this repository by creating an issue!

Unfortunately, your issue lacks vital information, such as log files, the error message, the software version, your configuration or other pieces of the puzzle.

Please also ensure that your issue is appropriately formatted. If you do not know how to write markdown, you can find help here.

Helping you with your problem is only possible if you share this information, and it will save a lot of time of back and forth on your as well as our end!

For this reason, this repository uses issue templates which you can select when pressing "New issue". Please use one of those issue templates to fill in the required information. You can either create a new issue for this purpose and close this one, or leave a comment.

Do not edit the original post as we will not be notified when you do so.

If you do not provide the requested information, this issue will be closed.

@und3fined
Copy link
Author

Describe the bug

  • I use client sdk: Regenerate OpenAPI client v0.5.5-alpha.2
  • Kratos v0.5.5-alpha.1
  • I don't know if it's kratos bug / kratos-client bug

In api public.Whoami(params *WhoamiParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*WhoamiOK, error)
It's not work with Authorization headers

If it's client bug then in here https:/ory/kratos-client-go/blob/eac42ac8684469e5cf19a75b6ea374d0a6a267f8/client/public/whoami_parameters.go#L157

If it's kratos bug, bug in here:

func (s *ManagerHTTP) extractToken(r *http.Request) string {

Reproducing the bug

  • Bug from kratos/ kratos-client , you can see code for bug.

Expected behavior

I can get a valid session

@ycgambo
Copy link
Contributor

ycgambo commented Apr 19, 2021

I'm using go client, don't know if the above pull fixes that.

github.com/ory/kratos-client-go v0.5.5-alpha.4
github.com/ory/kratos v0.5.5-alpha.1

here's the source code in kratos-client-go/client/public/whoami_parameters.go

	if o.Authorization != nil {

		// query param Authorization
		var qrAuthorization string

		if o.Authorization != nil {
			qrAuthorization = *o.Authorization
		}
		qAuthorization := qrAuthorization
		if qAuthorization != "" {

			if err := r.SetQueryParam("Authorization", qAuthorization); err != nil {
				return err
			}
		}
	}

but query param is not used in kratos/session/helper.go

func bearerTokenFromRequest(r *http.Request) (string, bool) {
	parts := strings.Split(r.Header.Get("Authorization"), " ")

	if len(parts) == 2 && strings.ToLower(parts[0]) == "bearer" {
		return parts[1], true
	}

	return "", false
}

@und3fined
Copy link
Author

@aeneasr any release for this fix?

harnash pushed a commit to Wikia/kratos that referenced this issue Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants