role

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

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 4 Imported by: 3

README

bulrush-role

Example

Basic permissions and role control.

  • EXAMPLE:
app.Use(&plugins.Role{
	FailureHandler: func(c *gin.Context, action string) {
		c.JSON(http.StatusForbidden, gin.H{
			"message": 	"No permission to access this api",
		})
	},
	RoleHandler:	func(c *gin.Context, action string) bool {
		fmt.Println("action :", action)
		return false
	},
	RoleHandler1:	func(c *gin.Context, action string) bool {
		fmt.Println("action :", action)
		return false
	},
})

app.Use(bulrush.PNQuick(func(testInject string, router *gin.RouterGroup, role *plugins.Role) {
	router.GET("/bulrushApp",
		role.Can("super@testPermts"),
		role.Can1("super@testPermts"),
		func (c *gin.Context) {
			c.JSON(http.StatusOK, gin.H{
				"message": 	testInject,
			})
	})
}))

API

RoleHandle defined api for role rule check
func RoleHandler(c *gin.Context, action string) bool

func RoleHandler1(c *gin.Context, action string) bool

func RoleHandler2(c *gin.Context, action string) bool

func RoleHandler3(c *gin.Context, action string) bool

func RoleHandler4(c *gin.Context, action string) bool

func RoleHandler5(c *gin.Context, action string) bool

func RoleHandler6(c *gin.Context, action string) bool
Can defined api for role rule use
func Can(action string) gin.HandlerFunc

func Can1(action string) gin.HandlerFunc

func Can2(action string) gin.HandlerFunc

func Can3(action string) gin.HandlerFunc

func Can4(action string) gin.HandlerFunc

func Can5(action string) gin.HandlerFunc

func Can6(action string) gin.HandlerFunc

MIT License

Copyright (c) 2018-2020 Double

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Roles []string
	// contains filtered or unexported fields
}

Action for role

func TransformAction

func TransformAction(action string) []Action

TransformAction action tran

type Role

type Role struct {
	FailureHandler func(*gin.Context, string)
	RoleHandler    func(*gin.Context, string) bool
	RoleHandler1   func(*gin.Context, string) bool
	RoleHandler2   func(*gin.Context, string) bool
	RoleHandler3   func(*gin.Context, string) bool
	RoleHandler4   func(*gin.Context, string) bool
	RoleHandler5   func(*gin.Context, string) bool
	RoleHandler6   func(*gin.Context, string) bool
}

Role for role

func (*Role) Can

func (role *Role) Can(action string) gin.HandlerFunc

Can do what

func (*Role) Can1

func (role *Role) Can1(action string) gin.HandlerFunc

Can1 do what

func (*Role) Can2

func (role *Role) Can2(action string) gin.HandlerFunc

Can2 do what

func (*Role) Can3

func (role *Role) Can3(action string) gin.HandlerFunc

Can3 do what

func (*Role) Can4

func (role *Role) Can4(action string) gin.HandlerFunc

Can4 do what

func (*Role) Can5

func (role *Role) Can5(action string) gin.HandlerFunc

Can5 do what

func (*Role) Can6

func (role *Role) Can6(action string) gin.HandlerFunc

Can6 do what

func (*Role) Plugin

func (role *Role) Plugin() *Role

Plugin for role

func (*Role) Pre

func (role *Role) Pre(c *bulrush.Config)

Pre for role

Jump to

Keyboard shortcuts

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