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

gocloak is broken for Keycloak v17.0 : need to remove /auth from the gocloak endpoint path #346

Closed
ksingh7 opened this issue Mar 28, 2022 · 9 comments · Fixed by #361
Closed

Comments

@ksingh7
Copy link

ksingh7 commented Mar 28, 2022

Describe the bug
Upon hitting any of the API calls i am getting error

404 Not Found: RESTEASY003210: Could not find resource for full path: http://localhost:8080/auth/realms/dev/protocol/openid-connect/token

To Reproduce
Steps to reproduce the behavior:

  1. Keycloak Version 17.0.1
  2. gocloak version 11.0.2
  3. Hit the gocloak api (any method)
jwt, err := keycloakClient.Login(
		kCTX,
		kCreds.clientId,
		kCreds.clientSecret, kCreds.realm,
		kCreds.username, kCreds.password,
	)

FYI direct CURL on keyckoak works fine

image

Expected behavior
We should able to successfully authenticatae using gocloak method
Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS
  • Browser [e.g. chrome, safari] Chrome

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Important : Starting 17.0+ version of Keycloak, there's a change in endpoints as per the official documentation, you need to omit /auth from the endpoint.
We need a mechanism in gocloak to omit \admin

@ksingh7
Copy link
Author

ksingh7 commented Mar 28, 2022

@Nerzal i would like to thank you for this wonderful Go Library. With this bug i wanted to bring it to your notice that gocloak endpoints are broken with latest version of keycloak (17.0). gocloak API uses an additional \auth in the route path that needs to be omited in order for it to work with keycloak v 17.0

@ksingh7 ksingh7 changed the title 404 Not Found: RESTEASY003210: Could not find resource for full path: http://localhost:8080/auth/realms/dev/protocol/openid-connect/token gocloak is broken for Keycloak v17.0 : need to remove /auth from the gocloak endpoint path Mar 28, 2022
@mbecker
Copy link

mbecker commented Apr 4, 2022

Hi,

see #252 how to change the endpoint`s paths.

Fully example for Keycloak 17:

package main

import (
	"context"
	"crypto/tls"
	"fmt"

	gocloak "github.com/Nerzal/gocloak/v11"
)

var URL string = "https://127.0.0.1:8443"

func main() {

	realm := "master"
	clientID := "my-resource-server"
	clientSecret := "***"

	client := gocloak.NewClient(URL, gocloak.SetAuthAdminRealms("admin/realms"), gocloak.SetAuthRealms("realms"))
	restyClient := client.RestyClient()
	restyClient.SetDebug(true)
	restyClient.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
	ctx := context.Background()
	token, err := client.LoginClient(ctx, clientID, clientSecret, realm)
	if err != nil {
		panic("Login failed:" + err.Error())
	}
	fmt.Println(token)
}

@Howard3
Copy link

Howard3 commented Apr 5, 2022

thanks @mbecker I can confirm this works.

@maitredede
Copy link

Hi,

I am using Keycloak 18 with lib v11.1.0. I have updated the options for the path change. The GetUserInfo works, but not the GetServerInfo : still 404. The source code shows hardcoded "auth" in makeURL call 😄

@tjarkmeyer
Copy link
Contributor

I found this in the migrating to quarkus guide:

Default context path changed
By default, the new Quarkus distribution removes /auth from the context-path. To re-introduce the /auth use the http-relative-path build option. For example:

bin/kc.[sh|bat] start-dev --http-relative-path /auth

https://www.keycloak.org/migration/migrating-to-quarkus

@ricardogayer
Copy link

Thanks mbecker for share this solutions!

@Nerzal
Copy link
Owner

Nerzal commented Jul 27, 2022

We've created a ticket to address this problem at my workplace.
This will be resolved soon :)

@Nerzal
Copy link
Owner

Nerzal commented Oct 13, 2022

Heyho everyone, here is an update:

I managed to pack this into a Task in the new sprint at work.
Also lots of nice people contributed lots of new features <3 thank you everyone!

I'm using the time at work to merge and test on the dev branch and then pack a new big release within the next days

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.

7 participants