mysql

package module
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

README

Permissions MYSQL Store

Usage

Make sure that sql service has been deployed.

import (
_ "github.com/aacfactory/fns-contrib/permissions/store/mysql"
)

Config setting

permissions:
  store:
    model: 
      schema: "schema"
      table: "table name"
    policy:
      schema: "schema"
      table: "table name"

DML

Model table

CREATE TABLE IF NOT EXISTS `YOUR TABLE` (
    `NAME`      VARCHAR (255),
    `PARENT`    VARCHAR (255) NOT NULL,
    `RESOURCES` JSON,
    `VERSION`   bigint,
    PRIMARY KEY (`NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Policy table

CREATE TABLE IF NOT EXISTS `YOUR TABLE` (
    `USER_ID`   VARCHAR (63),
    `ROLES`     VARCHAR (255) NOT NULL,
    `VERSION`   bigint,
    PRIMARY KEY (`USER_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Model  TableName
	Policy TableName
}

type ModelRow

type ModelRow struct {
	Name      string         `col:"NAME,pk" json:"NAME"`
	Parent    string         `col:"PARENT" json:"PARENT"`
	Resources map[string]int `col:"RESOURCES,json" json:"RESOURCES"`
	Version   int64          `col:"VERSION,aol"`
	// contains filtered or unexported fields
}

func (ModelRow) TableName

func (row ModelRow) TableName() (schema string, table string)

type PolicyRow

type PolicyRow struct {
	UserId  string   `col:"USER_ID,pk" json:"USER_ID"`
	Roles   []string `col:"ROLES,json" json:"ROLES"`
	Version int64    `col:"VERSION,aol"`
	// contains filtered or unexported fields
}

func (PolicyRow) TableName

func (row PolicyRow) TableName() (schema string, table string)

type Store

type Store struct {
	Model  TableName
	Policy TableName
	// contains filtered or unexported fields
}

func (*Store) Build

func (store *Store) Build(options permissions.StoreOptions) (err error)

func (*Store) Close

func (store *Store) Close() (err error)

func (*Store) RemoveRole

func (store *Store) RemoveRole(ctx context.Context, name string) (err error)

func (*Store) Role

func (store *Store) Role(ctx context.Context, name string) (role *permissions.Role, err error)

func (*Store) Roles

func (store *Store) Roles(ctx context.Context) (roles []*permissions.Role, err error)

func (*Store) SaveRole

func (store *Store) SaveRole(ctx context.Context, role *permissions.Role) (err error)

func (*Store) UserBindRoles

func (store *Store) UserBindRoles(ctx context.Context, userId string, roleNames ...string) (err error)

func (*Store) UserRoles

func (store *Store) UserRoles(ctx context.Context, userId string) (roles []*permissions.Role, err error)

func (*Store) UserUnbindRoles

func (store *Store) UserUnbindRoles(ctx context.Context, userId string, roleNames ...string) (err error)

type TableName

type TableName struct {
	Schema string
	Table  string
}

Jump to

Keyboard shortcuts

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