Skip to content

BE: RBAC: Support JSON path for roles-field #1025

Open
@exlosir

Description

@exlosir

Issue submitter TODO list

  • I've searched for an already existing issues here
  • I'm running a supported version of the application which is listed here and the feature is not present there

Is your proposal related to a problem?

I set up oauth2 authentication (keycloak) and rbac. I created client, role, user. Assing role to user. When i receive token - path to role field see like as realm_access.roles or altenative variant like this resource_access.KAFKA-UI-LOCAL.roles.
On site list of clusters is empty, because roles is not mapped to Keycloak roles.

Describe the feature you're interested in

As suggested by @germanosin, I would like to add the ability to specify a custom path for roles-field in the token by json-path

Describe alternatives you've considered

No response

Version you're running

3074abc

Additional context

Current configuration docker-compose

version: '3.8'

name: kafka-ui
services:
  app:
    image: ghcr.io/kafbat/kafka-ui:latest
    container_name: "kafka-ui-am"
    environment:
      SPRING_CONFIG_LOCATION: file:/etc/kafkaui/application.yml
      SPRING_PROFILES_ACTIVE: keycloak,rbac
      #SERVER_SERVLET_CONTEXT_PATH: /kafka-ui
    ports:
        - 8080:8080
    volumes:
      - ./application.yml:/etc/kafkaui/application.yml
    networks:
      - kafka-ui

networks:
  kafka-ui:

application.yml

kafka:
  clusters:
    - name: dev
      bootstrapServers: localhost:9092

logging:
  level:
    #ROOT: TRACE
    io.kafbat.ui.service.rbac.extractor: TRACE

auth:
  type: OAUTH2
  oauth2:
    client:
      keycloak:
        provider: keycloak
        clientId: KAFKA-UI-LOCAL
        clientSecret: some-secret-key
        scope: ['openid', 'roles']
        issuer-uri: https://localhost:8081/realms/master
        user-name-attribute: preferred_username
        client-name: keycloak
        custom-params:
          type: oauth
          roles-field: realm_access.roles

server:
  forward-headers-strategy: native # to make it work behind reverse-proxy

rbac:
  roles:
    - name: kafka-ui-readonly
      clusters:
        - dev
      subjects:
        - provider: oauth
          type: role
          value: kafka-ui-readonly
      permissions:
        - resource: clusterconfig
          actions: [ "view" ]

        - resource: topic
          value: ".*"
          actions: 
            - VIEW
            - MESSAGES_READ

        - resource: schema
          value: ".*"
          actions: [ view ]

        - resource: connect
          value: ".*"
          actions: [ view ]

        - resource: acl
          actions: [ view ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/rbacRelated to Role Based Access Control featurescope/backendRelated to backend changesstatus/triage/completedAutomatic triage completedtype/enhancementEn enhancement/improvement to an already existing feature

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions