Hi I am trying to make an authentication using Keycloak and Krakend, i can send my request, log in and then when i try to access the resource (using Insomnia) i get:
403 Forbidden: No body returned for response.
I don't know why this is its behaviour, please help!
This is my Krakend.json configuration file:
{
"$schema": "https://www.krakend.io/schema/v3.json",
"version": 3,
"timeout": "10s",
"name": "APIGateway",
"port": 8402,
"extra_config": {
"security/cors": {
"allow_origins": [
"*"
],
"allow_methods": [
"GET",
"POST",
"PUT",
"DELETE",
"HEAD"
],
"expose_headers": [
"Content-Length",
"Content-Type",
"Authorization"
],
"allow_headers": [
"*"
],
"allow_credentials": true,
"debug": true
}
},
"endpoints": [
{
"endpoint": "/go",
"method": "GET",
"output_encoding": "no-op",
"extra_config": {
"auth/validator": {
"alg": "RS256",
"roles": [
"user",
"admin"
],
"jwk_url": "http://192.168.3.10:8403/auth/realms/pippo/protocol/openid-connect/certs",
"disable_jwk_security": true
}
},
"backend": [
{
"url_pattern": "/api",
"host": [
"http://192.168.3.10:8080"
]
}
]
}
]
}
In Keycloak i created my realm, user with credentials (using admin permissions) and client, i think it's correct because my login with access token works fine, after the login I got 403.
Here's my service written in go:
func JSONHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"ciao": "ciao"})
}
func Init() {
router := gin.Default()
router.Use(middlewares.CORS())
router.GET("/api", JSONHandler)
err := router.Run(":8080")
if err != nil {
log.Fatal("Oh no")
}
}
Modifying the field:
"$schema": "https://www.krakend.io/schema/v3.json"
to
"$schema": "https://www.krakend.io/schema/v2.4.3.json"
solved my problem!