Giter Site home page Giter Site logo

h4ckedneko / casbin-httpfs Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 8 KB

A convenient http.FileSystem adapter for Casbin v2.

Home Page: https://pkg.go.dev/github.com/h4ckedneko/casbin-httpfs

License: MIT License

Makefile 2.86% Go 97.14%
go golang casbin httpfs adapter wrapper static

casbin-httpfs's Introduction

Casbin HTTP FileSystem Adapter

GoDoc Reference Latest Version License Name Build Status Coverage Status Report Card Status

Package casbin-httpfs is a convenient http.FileSystem adapter for Casbin v2. It enables Casbin to load policy and model from anything that implements the http.FileSystem interface.

Installation

Make sure you have a working Go workspace, then:

go get github.com/h4ckedneko/casbin-httpfs

For updating to latest stable release, do:

go get -u github.com/h4ckedneko/casbin-httpfs

Usage

Here is a basic example for this package:

package main

import (
	"net/http"

	"github.com/casbin/casbin/v2"
	casbinfs "github.com/h4ckedneko/casbin-httpfs"
)

var fs http.FileSystem = http.Dir("/")

func main() {
	// Initialize a new adapter instance.
	adapter := casbinfs.NewAdapter(fs, "/path/to/policy.csv")

	// Initialize a new enforcer instance by passing the adapter.
	enforcer, _ := casbin.NewEnforcer("/path/to/model.conf", adapter)

	// Start checking for permissions.
	enforcer.Enforce("alice", "data1", "read")
}

License

MIT © Lyntor Paul Figueroa. See LICENSE for full license text.

casbin-httpfs's People

Contributors

h4ckedneko avatar

Watchers

Eric Luo avatar  avatar

casbin-httpfs's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.