Skip to content

azarenkov/keyclock-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Keycloak Json Web Tokens Docker Git

Keycloak Integration Example

This project demonstrates integration with Keycloak for authentication and authorization using Rust and Actix-web framework.

API Endpoints

Authentication Flow

1. Login Endpoint

  • URL: /login
  • Method: GET
  • Description: Initiates the authentication flow by redirecting to Keycloak login page
  • Response: Redirects to Keycloak authentication page

2. Callback Endpoint

  • URL: /callback
  • Method: GET
  • Query Parameters:
    • code: Authorization code from Keycloak
    • session_state: Session state
    • iss: (Optional) Issuer
  • Description: Handles the OAuth2 callback from Keycloak
  • Response:
    • Sets access_token cookie
    • Returns HTML page with token information

Protected Routes

All protected routes are under /api/v1 and require Bearer token authentication.

Protected Resource

  • URL: /api/v1/protected
  • Method: GET
  • Headers Required:
    • Authorization: Bearer <access_token>
  • Description: Example of a protected resource
  • Response:
    • Success (200): Returns "Access to protected resource granted!"
    • Unauthorized (401): When token is invalid or missing

Logout

  • URL: /api/v1/logout
  • Method: POST
  • Headers Required:
    • Authorization: Bearer <access_token>
  • Description: Ends the user session
  • Response:
    • Success (302): Redirects to /login
    • Error (400): When token is missing
    • Error (500): When logout fails

About

Keycloak integration with Rust and Actix-Web

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors