ekuinox / red_drink

気持ち的には家のサーバのダッシュボード的なのが作りたい

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

なんもわからん、PermissionとResourceがテーブルにある必要ないんじゃないか

ekuinox opened this issue · comments

AccessiblesにJSONで定義持たせたほうがいいじゃないのか

一生進まんぞこれ!

構想

User = {
    roles: Role[]
}

Role = {
    policies: Policy[]
}

Policy = {
    priority: u32
    accessible: Allowed | Denied
    resources: ResourceId[]
    permissions: Permission[]
}

ResourceId = [resourceType, resourceId]
Permission = String // dotted eg. foo.bar.*

Permission(self).get_parents() => String[] // eg. ["*", "foo.*", "foo.bar.*", "foo.bar.*"]
 
user {
    roles: [
        {
            policies: [{
                allowed: {
                    resources: [ResourceId("action", "11111")],
                    permissions: ["action.*"]
                }
            }]
        }
    ]
}

ExecutableContext {
    user: User
    resources: [
        [resourceId, ["action.invoke"]]
    ]
}

{ user, resources } = ExecutableContext()
// user は リソース resources[@][0: resourceId] に対する 権限 resources[@][1: permissions] を持っているか

#17 (comment)
PolicyからVecにしたいなあとは思うんですが、いうていらんかもしれん...

あとテストがコケてる...なんで...