Google Sign-In Required

Use your company Google account to access the BetterFleet private content.

Back to private home

BetterFleet Support Private
Skip to content
BetterFleet Dev Wiki
Web Model
Initializing search
    bf-dev
    • Home
    • Product Capabilities
    • Process
    • Current Work
    • System Design
    • Software Reference
    • Operations
    bf-dev
    • Home
      • Overview
      • Manage
      • Overview
      • Product Engineering Workflow
      • Product Engineering Delivery
      • Product Engineering Workflow in Linear
        • GitLab Feature Flags
        • In-App Docs Authoring
        • Release Notes
      • Templates
      • Publishing
      • Workflow Companions
      • Overview
      • Active Artifacts
      • Backlog Artifacts
      • Archived Artifacts
      • Overview
      • Microgrid
      • OSCP
        • Challenge
        • Specification
        • Spec
        • Architecture
        • Overview
        • Script Runtime Model
        • Compose Profiles and Modes
        • Repo Topology
        • CI and Release Integration
        • Overview
        • Internal Application Diagrams
          • Overview
          • Web Model
            • Session and identity loading
            • Request authentication path
            • UI permission gating
            • Route guarding
            • Security posture in web layer
          • Core Model
        • Service Interaction Flows
        • Data and State
          • Index
          • bf-manage-web
          • bf-manage-core
          • bf-manage-connect
          • bf-manage-sitepwrmon
          • bf-manage-incidents
          • bf-telematics
          • bf-depot-sim
          • bf-manage-roaming
          • bf-support-microsite
          • bf-digital-twin
          • bf-schedule-creator
        • Overview
        • Internal Application Diagrams
        • Migration and Flags
        • Simulation Request Lifecycle
          • Index
          • bf-bnl-ui
          • bf-bnl-settings
          • bf-bnl-schedule-analysis-compute
          • bf-route-modelling
          • bf-schedule-creator
          • bf-digital-twin
        • Overview
        • Secrets and Env Strategy
        • Vendors and Local Dependencies
        • ADRs
        • Service Matrix
        • Cloud Dependencies
        • Ports and URLs
      • Onboarding
      • Daily Operations Runbook
        • Overview
        • Staging Hotfix Release
        • Production Hotfix Release
        • Terraform Plan Dry Runs
      • Troubleshooting
      • Testing Guide
    • Session and identity loading
    • Request authentication path
    • UI permission gating
    • Route guarding
    • Security posture in web layer

    bf-manage-web Auth and Permission Model¶

    Session and identity loading¶

    AuthProvider (src/context/authContext.tsx) calls /auth/users/me via useGetManageUser and stores:

    • authenticated user payload
    • workspace_acl
    • selected workspace in session/local storage

    Primary workspace selectors are stored as:

    • localStorage.account_id
    • sessionStorage.workspace_id
    • optional sessionStorage.depot_id

    Request authentication path¶

    useAxios (src/hooks/useAxios.ts) request interceptor:

    1. fetches current Amplify session
    2. refreshes token if missing or expired
    3. sets Authorization: Bearer <token>
    4. sends scope headers (x-account-id, x-workspace-id, x-depot-id)
    flowchart TD
      Request[Client request] --> Session[fetch auth session]
      Session --> Refresh{Token valid}
      Refresh -- No --> ForceRefresh[force refresh token]
      Refresh -- Yes --> Headers[attach auth and scope headers]
      ForceRefresh --> Headers
      Headers --> Send[send axios request]

    UI permission gating¶

    useCheckPermission (src/services/permissions.ts) uses:

    • selected workspace role (workspace.role_name)
    • static permission matrix in frontend
    • admin bypass for user.is_admin

    This powers conditional UI behavior across navigation, pages, and action controls.

    flowchart TD
      WorkspaceRole[Workspace role name] --> Matrix[Frontend permission matrix]
      UserAdmin[User admin flag] --> Bypass{Is admin}
      Bypass -- Yes --> Allowed[Allow action in UI]
      Bypass -- No --> Matrix
      Matrix --> FeatureOp[Feature and operation check]
      FeatureOp --> UiDecision[Show or hide action]

    Route guarding¶

    ProtectedRoute currently guards for depot availability and optional SPA auto-reload flag behavior. It is not the primary authorization enforcement mechanism.

    Security posture in web layer¶

    • Prevents accidental unavailable actions in UI.
    • Does not replace backend authorization checks.
    • Always rely on backend for final permission enforcement.
    Made with Material for MkDocs