Skip to main content

Casbin Authorization Configuration

The authz-casbin plugin authorizes requests on routes and services with Casbin models and policies using a request header, path, and HTTP method. Configuration covers plugin parameters and plugin metadata.

Parameters​

See plugin common configurations for configuration options available to all plugins.

  • model_path

    string


    Path to a Casbin model file accessible to the gateway process.

    Mount the model and policy files at the configured paths on every gateway instance. Changing file contents alone does not rebuild the cached enforcer.

    Configure model_path, policy_path, and username together, or use one of the text-based configurations described below.

  • policy_path

    string


    Path to a Casbin policy file accessible to the gateway process.

    Configure model_path, policy_path, and username together.

  • model

    string


    Casbin model in text format.

    Configure model, policy, and username together. A route-level model and policy take precedence over plugin metadata.

  • policy

    string


    Casbin policy in text format.

    Configure model, policy, and username together. A route-level model and policy take precedence over plugin metadata.

  • username

    string

    required


    Request header whose value is used as the Casbin subject. A request without the header uses anonymous as the subject.

Plugin Metadata​

Routes configured with only username depend on complete model and policy metadata. If the metadata is unavailable or incomplete, requests return 503 Service Unavailable.

  • model

    string

    required


    Shared Casbin model in text format. Routes can use it by configuring the plugin with only username.

  • policy

    string

    required


    Shared Casbin policy in text format. Updating the metadata applies the new policy to routes that use the shared configuration.