sql

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

README

SQL

sql based rbac store

Install

go get github.com/aacfactory/fns-contrib/permissions/rbac/sql

Usage

app.Deploy(rbac.New(sql.Store()))

Config

rbac:
  sql:
    endpoint: "endpoint name of sql service"
    roleTable: 
      schema: "schema"
      table: "table"
    userTable:
      schema: "schema"
      table: "table"
    cache:
      disable: false
      rolesTTL: "24h0m0s"
      userRolesTTL: "1h0m0s"

Table schema

Column Type Not null Remark
ID string yes pk
CREATE_BY string yes
CREATE_AT time yes UTC
MODIFY_BY string no
MODIFY_AT time no UTC
VERSION int64 yes
NAME string yes unique
DESCRIPTION string no
PARENT_ID string no
POLICIES json bytes yes array

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Store

func Store() rbac.Store

Types

type CacheConfig added in v1.2.1

type CacheConfig struct {
	Disable      bool          `json:"disable"`
	RolesTTL     time.Duration `json:"rolesTTL"`
	UserRolesTTL time.Duration `json:"userRolesTTL"`
}

type Config

type Config struct {
	Endpoint  string      `json:"endpoint"`
	RoleTable TableConfig `json:"roleTable"`
	UserTable TableConfig `json:"userTable"`
	Cache     CacheConfig `json:"cache"`
}

type Policy

type Policy struct {
	Object string `json:"object"`
	Action string `json:"action"`
}

type Role added in v1.2.1

type Role struct {
	Id          string           `column:"ID,pk" json:"id" tree:"ParentId+Children"`
	CreateBY    string           `column:"CREATE_BY,acb" json:"createBY"`
	CreateAT    sql.NullDatetime `column:"CREATE_AT,act" json:"createAT"`
	ModifyBY    string           `column:"MODIFY_BY,amb" json:"modifyBY"`
	ModifyAT    sql.NullDatetime `column:"MODIFY_AT,amt" json:"modifyAT"`
	Version     int64            `column:"VERSION,aol" json:"version"`
	Name        string           `column:"NAME" json:"name"`
	Description string           `column:"DESCRIPTION" json:"description"`
	ParentId    string           `column:"PARENT_ID" json:"parentId"`
	Policies    []Policy         `column:"POLICIES,json" json:"policies"`
}

func (Role) TableInfo added in v1.2.1

func (row Role) TableInfo() dac.TableInfo

type TableConfig added in v1.2.1

type TableConfig struct {
	Schema string `json:"schema"`
	Table  string `json:"table"`
}

type UserRole added in v1.2.1

type UserRole struct {
	Id      string   `column:"ID,pk" json:"id"`
	RoleIds []string `column:"ROLE_IDS,json" json:"roleIds"`
	Version int64    `column:"VERSION,aol" json:"version"`
}

func (UserRole) TableInfo added in v1.2.1

func (row UserRole) TableInfo() dac.TableInfo

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL