Skip to main content

Adapters

This guide explains adapters. In Casbin, an adapter loads and saves policy rules, for example from a database table. In Casdoor, you configure an adapter in the admin console and then view and edit its policies there.


Learning outcomes​

  • Connect an adapter to a database table.
  • Load the policies and add, edit, and delete them.

What you need​

  • A database that Casdoor can reach

Configure the adapter​

  1. In the Casdoor admin console, open the Adapters page and add an adapter.

  2. Fill in the fields:

    FieldDescription
    TypeKind of adapter. Only Database is available
    Host, Port, User, PasswordConnection to the database
    Database typeMySQL, PostgreSQL, SQL Server, Oracle, or SQLite 3
    DatabaseName of the database
    TableName of the table. Casdoor creates it if it doesn't exist

    Adapter edit page

  3. Save the adapter.

  4. Click Sync to load the policies into the table on the page.

    Policies of the adapter

Edit the policies​

Add a policy, one at a time:

Recording of adding a policy

A new policy appears at the top of the table but is stored at the end. After the next sync, it appears in the stored order.

Edit a policy:

Recording of editing a policy

Delete a policy:

Recording of deleting a policy

See also​