/demo-yew-rbac

A Yew-based RBAC (Role-Based Access Control) demo application.

Primary LanguageRust

Demo Yew RBAC

A demonstration of Role-Based Access Control (RBAC) implementation using the Yew web framework in Rust.

Project Structure

src/
├── main.rs          # Application entry point
├── pages.rs         # Page components and login logic
├── router.rs        # Route definitions and protected route logic
└── state.rs         # Global state management (AuthState, Role enum)

Getting Started

Prerequisites

  • Trunk for building and serving

Installation

  1. Clone the repository:
git clone <repository-url>
cd demo-yew-rbac
  1. Install Trunk (if not already installed):
cargo install trunk
  1. Build and serve the application:
trunk serve
  1. Open your browser and navigate to http://localhost:8080

Usage

Demo Credentials

The application includes mock authentication with the following test accounts:

Username Password Role
mobu 1234 Mobu
fighter 5678 Fighter
master 9999 Master

How to Test

  1. Login: Enter any of the demo credentials above
  2. Role-Based Access: Each role can only access their designated page:
    • /mobu - Accessible only by users with Mobu role
    • /fighter - Accessible only by users with Fighter role
    • /master - Accessible only by users with Master role
  3. Navigation: Use the navigation links to test protected route behavior
  4. Logout: Click the logout button to clear the session