keycloak-bff-auth

Implement Keycloak BFF authentication with OIDC, JWT verification, and RBAC middleware.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/thehivegroup-ai/ai-development --skill keycloak-bff-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: keycloak-bff-auth
Source: https://github.com/thehivegroup-ai/ai-development/tree/main/modules/stack-authorities/authentication/keycloak-bff/skills/keycloak-bff-auth
Command: npx skills add https://github.com/thehivegroup-ai/ai-development --skill keycloak-bff-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill addresses the complexities of implementing and managing Keycloak authentication, providing a comprehensive solution for OIDC integration, JWT verification, and RBAC middleware in web applications.

Core Features & Use Cases

  • Keycloak BFF Integration: Centralizes Keycloak authentication, handling all authentication-related operations within the backend (BFF).
  • JWT Handling: Offers robust JWT verification, enabling secure user identification and role management.
  • RBAC Middleware: Integrates role-based access control to secure API routes and user operations.
  • Frontend Token Management: Assists with the management of tokens for seamless user experiences on the client-side.
  • Test Mode: Supports development and testing without a Keycloak instance using self-signed tokens.

Quick Start

Install and set up the keycloak-bff-auth Skill. For local development, ensure the Keycloak environment is ready with realm and client configurations. Set environment variables and deploy your application.

Frequently Asked Questions about keycloak-bff-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement Keycloak BFF authentication in my web application?

Keycloak BFF authentication centralizes OAuth2 (OIDC) operations in the backend. You handle JWT verification and RBAC middleware by setting up a Keycloak environment, configuring realms and clients, and managing frontend tokens for secure user identification and route protection.

What is the BFF pattern for OIDC and JWT verification?

The BFF pattern for OIDC centralizes authentication in the backend, removing token handling from the browser. It performs JWT verification to securely identify users and manage roles, ensuring API routes and user operations are protected by RBAC middleware.

Can I test Keycloak JWT verification locally without a running Keycloak instance?

Yes, you can test JWT verification locally without a Keycloak instance using the Skill's test mode. This mode supports development and testing by generating and validating self-signed tokens, allowing you to build and test RBAC middleware independently.

What environment variables do I need for Keycloak BFF integration and JWT handling?

Keycloak BFF integration requires setting the JWT_SECRET environment variable to sign and verify tokens. You also need to configure client-side token management settings and ensure your Keycloak realm and client configurations are properly defined.

Does this approach handle role-based access control for API routes?

Yes, the BFF approach integrates role-based access control (RBAC) middleware to secure API routes. By verifying JWTs issued by Keycloak, the backend enforces role-based permissions, ensuring only authorized users can access specific operations and endpoints.

What are the limitations of using self-signed tokens in test mode?

Self-signed tokens in test mode bypass actual Keycloak OIDC flows for local development convenience. This limitation means you cannot fully validate real-world OAuth2 provider configurations, token lifecycles, or external client-side token management behaviors until integration.