go_rbac

package module
v0.0.0-...-b2c9916 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: GPL-3.0 Imports: 5 Imported by: 1

README

go-rbac

GoDoc

dccn-rbac-{app, web} project client package

Documentation

Overview

Copyright 2019 The Ankr crop. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Package go_rbac provides RBAC client implementations.

create new client:

	c, err := New("127.0.0.1:6801")
    ...

authorize something:

   rsp, err := c.Authorize(ctx, &Request{
		Subject:  "ankr",
		Resource: "/v1/path/to/rc",
		Action:   "read",
	})
   ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Close() error
	Authorize(ctx context.Context, req *Request) (*Response, error)
}

func New

func New(srvAddr string) (Client, error)

New create new client for remote rbac server

type ConfigMgr

type ConfigMgr struct {
	Addr string
}

func NewDefaultConfigMgr

func NewDefaultConfigMgr() *ConfigMgr

type Manager

type Manager interface {
	AddRole(ctx context.Context, roleName string) error
	UserBindRole(ctx context.Context, user, role string) error
	AddPolicy(ctx context.Context, catalog, subject, resource, action, policy string) error
}

func NewManager

func NewManager() Manager

type Policy

type Policy struct {
	Id       int64
	Type     string
	Subject  string
	Resource string
	Action   string
	Permit   string
	Status   int64
}

type QueryReq

type QueryReq struct {
	Page int64
	Size int64
	Type string
}

type Request

type Request struct {
	// the executor which execute the spec action
	Subject string
	// the resource such as  the name of data
	// or the name of url(/v1/path/to/role) and so on.
	Resource string
	// the action such as Read, Write, PUT, POST and so on,
	// it which exists in reality is valid and reasonable.
	Action string
}

type Resource

type Resource struct {
	Id     int64
	Type   string
	Name   string
	Value  string
	Source string
	Memo   string
	Status int64
}

type ResourceAddRequest

type ResourceAddRequest struct {
	Type   string
	Name   string
	Value  string
	Source string
	Memo   string
}

type ResourceAddResponse

type ResourceAddResponse struct {
	Resp
}

type ResourceDelRequest

type ResourceDelRequest struct {
	ID int64
}

type ResourceDelResponse

type ResourceDelResponse struct {
	Resp
}

type ResourceMgr

func NewResourceMgr

func NewResourceMgr(cfg ConfigMgr) ResourceMgr

NewResourceMgr feature 1. weather to choose keep-live feature, I think about it for long time, at last I decide to take it, because as usual, our network is the internal and stable, if appear error when use role manager, please recreate it 2. if the network is not stable, the action of create role manager will go on until create it successfully.

type ResourceModRequest

type ResourceModRequest struct {
	Resource
}

type ResourceModResponse

type ResourceModResponse struct {
	Resp
}

type ResourceQryRequest

type ResourceQryRequest struct {
	QueryReq
}

type ResourceQryResponse

type ResourceQryResponse struct {
	Resp
	Total int64
	Data  []*Resource
}

type Resp

type Resp struct {
	Code int64
	Desc string
}

type Response

type Response struct {
	// true means passed.
	// false means failed.
	OK bool
}

judge result response

type Role

type Role struct {
	Id     int64
	Name   string
	Type   string
	Memo   string
	Status int64
}

type RoleAddRequest

type RoleAddRequest struct {
	Type string
	Name string
	Memo string
}

type RoleAddResponse

type RoleAddResponse struct {
	Resp
}

type RoleBindingResource

type RoleBindingResource struct {
	Id       int64
	Type     string
	Subject  string
	Resource string
	Action   string
	Policy   string
	Status   int64
}

type RoleBindingResourceAddRequest

type RoleBindingResourceAddRequest struct {
	Type     string
	Subject  string
	Resource string
	Action   string
	Policy   string
}

type RoleBindingResourceAddResponse

type RoleBindingResourceAddResponse struct {
	Resp
}

type RoleBindingResourceDelRequest

type RoleBindingResourceDelRequest struct {
	Id int64
}

type RoleBindingResourceDelResponse

type RoleBindingResourceDelResponse struct {
	Resp
}

type RoleBindingResourceListRequest

type RoleBindingResourceListRequest struct {
	Type string
}

type RoleBindingResourceListResponse

type RoleBindingResourceListResponse struct {
	Resp
	Data []*RoleBindingResource
}

type RoleBindingResourceModRequest

type RoleBindingResourceModRequest struct {
	Policy
}

type RoleBindingResourceModResponse

type RoleBindingResourceModResponse struct {
	Resp
}

type RoleBindingResourceQryRequest

type RoleBindingResourceQryRequest struct {
	QueryReq
}

type RoleBindingResourceQryResponse

type RoleBindingResourceQryResponse struct {
	Resp
	Total int64
	Data  []*Policy
}

type RoleDelRequest

type RoleDelRequest struct {
	ID int64
}

type RoleDelResponse

type RoleDelResponse struct {
	Resp
}

type RoleMgr

func NewRoleMgr

func NewRoleMgr(cfg *ConfigMgr) RoleMgr

NewRoleMgr create role manager handler feature 1. weather to choose keep-live feature, I think about it for long time, at last I decide to start it, because as usual, our network is the internal and stable, if appear error when use role manager, please recreate it 2. if the network is not stable, the action of create role manager will go on until create it successfully.

type RoleModRequest

type RoleModRequest struct {
	Role
}

type RoleModResponse

type RoleModResponse struct {
	Resp
}

type RoleQryRequest

type RoleQryRequest struct {
	QueryReq
}

type RoleQryResponse

type RoleQryResponse struct {
	Resp
	Total int64
	Data  []*Role
}

type User

type User struct {
	Id     int64
	Type   string
	User   string
	Role   string
	Status int64
}

type UserAddRequest

type UserAddRequest struct {
	Type string
	User string
	Role string
}

type UserAddResponse

type UserAddResponse struct {
	Resp
}

type UserDelRequest

type UserDelRequest struct {
	Id int64
}

type UserDelResponse

type UserDelResponse struct {
	Resp
}

type UserListRequest

type UserListRequest struct {
	Type string
}

type UserListResponse

type UserListResponse struct {
	Resp
	Data []*User
}

type UserModRequest

type UserModRequest struct {
	User *User
}

type UserModResponse

type UserModResponse struct {
	Resp
}

type UserQryRequest

type UserQryRequest struct {
	Page int64
	Num  int64
	Type string
}

type UserQryResponse

type UserQryResponse struct {
	Resp
	Data  []*User
	Total int64
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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