minioadapter

package module
v0.0.0-...-5e9b361 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 10 Imported by: 0

README

casbin-minio-adapter

Go Report Card Build Status Coverage Status Godoc

Casbin adapter implementation using Minio/AWS S3 policy storage

Installation

go get github.com/Soluto/casbin-minio-adapter

Usage

import (
    minioadapter "github.com/Soluto/casbin-minio-adapter"
    "github.com/casbin/casbin"
)

func main() {

    adapter, _ := minioadapter.NewAdapter("http://minio-endpoint", "accessKey", "secretKey", false, "casbin-bucker", "policy.csv")

    enforcer := casbin.NewSyncedEnforcer("rbac_model.conf", adapter)

}

Additional Usage Examples

For real-world example visit Tweek.

License

This project is under MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdapter

func NewAdapter(endpoint string, accessKey string, secretKey string, secure bool, bucket string, objectName string) (persist.Adapter, error)

NewAdapter create new MinioAdapter Parameters:

  • endpoint URL to object storage service.
  • accessKey Access key is the user ID that uniquely identifies your account.
  • secretKey Secret key is the password to your account.
  • secure Set this value to 'true' to enable secure (HTTPS) access.
  • bucket Name of the bucket where the policy is stored
  • objectName Name of the object that contains policy

Types

type MinioAdapter

type MinioAdapter struct {
	// contains filtered or unexported fields
}

MinioAdapter the struct that implements

func (*MinioAdapter) AddPolicy

func (a *MinioAdapter) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.

func (*MinioAdapter) LoadPolicy

func (a *MinioAdapter) LoadPolicy(model model.Model) error

LoadPolicy loads all policy rules from the storage.

func (*MinioAdapter) RemoveFilteredPolicy

func (a *MinioAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.

func (*MinioAdapter) RemovePolicy

func (a *MinioAdapter) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.

func (*MinioAdapter) SavePolicy

func (a *MinioAdapter) SavePolicy(model model.Model) error

SavePolicy saves all policy rules to the storage.

Jump to

Keyboard shortcuts

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