MCPcopy Index your code
hub / github.com/dobyte/gf-casbin

github.com/dobyte/gf-casbin @v0.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.1 ↗ · + Follow
23 symbols 55 edges 3 files 17 documented · 74%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

gf-casbin

GoFrame Permission Plugin

Support MySQL, SQLite, PostgreSQL, Oracle, SQL Server Power By GoFrame ORM

Use

Download and install

go get github.com/dobyte/gf-casbin

Demo

package main

import (
    "fmt"
    "log"
    "github.com/dobyte/gf-casbin"
)

func main() {
    enforcer, err := casbin.NewEnforcer(&casbin.Options{
        Model:     "./example/model.conf",
        Debug:     false,
        Enable:    true,
        AutoLoad:  true,
        Table:   "casbin_policy_test",
        Link:    "mysql:root:123456@tcp(127.0.0.1:3306)/topic1",
    })

    if err != nil {
        log.Fatalf("Casbin init failure:%s \n", err.Error())
    }

    // add a permission node for role
    ok, err := enforcer.AddPolicy("role_1", "node_1")

    if err != nil {
        log.Fatalf("Add policy exception:%s \n", err.Error())
    }

    if ok {
        log.Println("Add policy successful")
    } else {
        log.Println("Add policy failure")
    }
}

Example

View demo example/main.go

Model Demo

View demo example/model.conf

Core symbols most depended-on inside this repo

Shape

Method 15
Function 4
Struct 4

Languages

Go100%

Modules by API surface

adapter.go19 symbols
example/main.go2 symbols
enforcer.go2 symbols

For agents

$ claude mcp add gf-casbin \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page