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_secret should be optional with authorization_code + PKCE flow #41

Open
lanwen opened this issue Sep 5, 2022 · 3 comments
Open

Comments

@lanwen
Copy link

lanwen commented Sep 5, 2022

Since this flow is intended to be adopted by native and web apps, most of the services (such as auth0 for instance) allow to omit client_secret, as it's anyway insecure.

Would be nice to have it as a config option or a way to override

@laduke
Copy link

laduke commented Apr 26, 2023

did you find a workaround?

@lanwen
Copy link
Author

lanwen commented Apr 26, 2023

@laduke Yes, I had to fork it
main...lanwen:mockoidc:client-secret-ignore

@rendicott
Copy link

rendicott commented Feb 13, 2024

I was just tacking on client_secret into my token exchange request arbitrarily in my redirect handler to get around this.

func testDirectedHandler(w http.ResponseWriter, r *http.Request) {
	var httpCookies []*http.Cookie
	cookieNonce, err := r.Cookie(cookieNameNonce)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte("error getting nonce cookie"))
		return
	}
	cookiePkce, err := r.Cookie(cookieNamePkce)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte("error getting pkce cookie"))
		return
	}
	httpCookies = append(httpCookies, cookieNonce)
	httpCookies = append(httpCookies, cookiePkce)
	rauT := fmt.Sprintf("http://%s%s?%s&client_secret=%s",
		r.URL.Host,
		r.URL.Path,
		r.URL.RawQuery,
		testDirectedClientSecret,
	)
	rau, err := url.Parse(rauT)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte("error parsing directed request URL"))
		return
	}

	cookieAccessToken, _, err := testDirectedAuthenticator.ValidateURLAndExchangeToken(
		rau, // give the URL path to be parsed
		httpCookies,
	)
...

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

No branches or pull requests

3 participants