authorizer

package
v0.8.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MemberTypeObserver      = "observer"
	MemberTypeOperator      = "operator"
	MemberTypeAdministrator = "administrator"
	MemberTypeOwner         = "owner"
)
View Source
const (
	DeviceAccept = iota
	DeviceReject
	DeviceRemove
	DeviceConnect
	DeviceRename
	DeviceDetails

	SessionPlay
	SessionClose
	SessionRemove
	SessionDetails

	FirewallCreate
	FirewallEdit
	FirewallRemove

	PublicKeyCreate
	PublicKeyEdit
	PublicKeyRemove

	NamespaceCreate
	NamespaceRename
	NamespaceAddMember
	NamespaceRemoveMember
	NamespaceEditMember
	NamespaceEnableSessionRecord
	NamespaceDelete

	BillingChooseDevices
	BillingAddPaymentMethod
	BillingUpdatePaymentMethod
	BillingRemovePaymentMethod
	BillingCancelSubscription
	BillingCreateSubscription
	BillingGetPaymentMethod
	BillingGetSubscription
)

Variables

View Source
var Actions = actions{
	Device: deviceActions{
		Accept:  DeviceAccept,
		Reject:  DeviceReject,
		Remove:  DeviceRemove,
		Connect: DeviceConnect,
		Rename:  DeviceRename,
	},
	Session: sessionActions{
		Play:    SessionPlay,
		Close:   SessionClose,
		Remove:  SessionRemove,
		Details: SessionDetails,
	},
	Firewall: firewallActions{
		Create: FirewallCreate,
		Edit:   FirewallEdit,
		Remove: FirewallRemove,
	},
	PublicKey: publicKeyActions{
		Create: PublicKeyCreate,
		Edit:   PublicKeyEdit,
		Remove: PublicKeyRemove,
	},
	Namespace: namespaceActions{
		Create:              NamespaceCreate,
		Rename:              NamespaceRename,
		AddMember:           NamespaceAddMember,
		RemoveMember:        NamespaceRemoveMember,
		EditMember:          NamespaceEditMember,
		EnableSessionRecord: NamespaceEnableSessionRecord,
		Delete:              NamespaceDelete,
	},
	Billing: billingActions{
		ChooseDevices:       BillingChooseDevices,
		AddPaymentMethod:    BillingAddPaymentMethod,
		UpdatePaymentMethod: BillingUpdatePaymentMethod,
		RemovePaymentMethod: BillingRemovePaymentMethod,
		CancelSubscription:  BillingCancelSubscription,
		CreateSubscription:  BillingCreateSubscription,
		GetSubscription:     BillingGetSubscription,
	},
}

Actions has all available and allowed actions. You should use it to get the code's action.

Functions

func EvaluatePermission

func EvaluatePermission(userType string, action int) bool

EvaluatePermission checks if the user's type has the permission to execute an action.

func EvaluateType

func EvaluateType(firstType, secondType string) bool

EvaluateType checks if the first type has a great value than second.

func GetAllMemberTypes

func GetAllMemberTypes() []string

GetAllMemberTypes return a list with all member types. What out, when you add a new type, you need to add it to this return list.

func GetTypeCode

func GetTypeCode(memberType string) int

GetTypeCode converts a member's type to an int.

Types

type Action

type Action int

Jump to

Keyboard shortcuts

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