Keycloak : Failed to Obtain Policy Enforcer Error

62 Views Asked by At

Problem:

I'm currently using Keycloak 15.0.1 with Spring Boot 2.7.15 within a Docker environment. Approximately six months ago, I successfully built the application, and it has been functioning as expected since then. I haven't made any changes to either the application or the Keycloak container. However, I now intend to add more functionality. When attempting to make various requests, including those to accessible endpoints, I encounter the same error consistently.

Description of the Problem:

Upon inspecting the Docker container logs for Keycloak, I noticed the following entry: docker container logs

The error I encounter when making any request is depicted below:

What I Have Tried:

I attempted to make the request directly from Postman to Keycloak and succeeded: postman

Additionally, I verified that the YAML configuration matches that of Keycloak, and it indeed matches:

# spring config
spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          issuer-uri: http://localhost:8080/auth/realms/JCRAM

# keycloak config
keycloak:
  cors: false
  cors-allowed-methods: POST, PUT, DELETE, GET
  cors-allowed-headers: X-Requested-With, Content-Type, Authorization, Origin, Accept, Access-Control-Request-Method, Access-Control-Request-Headers, Access-Control-Allow-Origin
  realm: JCRAM
  auth-server-url: http://localhost:8080/auth
  resource: JC-client
  ssl-required: external
  credentials:
    secret: #########################
  use-resource-role-mappings: true
  policy-enforcer-config:
    http-method-as-scope: true
    paths:
      - name: insecure Resource
        path: /auth/keycloak/*
        enforcement-mode: DISABLED
  security-constraints:
    - auth-roles:
        - "*"
      security-collections:
        - name:
          patterns:
            - /api/v1/*
            - /api/juriste/*
            - /api/all/*

**For additional configuration screenshots, please let me know, and I'll provide them. **

0

There are 0 best solutions below