oktarolemanager

package module
v0.0.0-...-3176e17 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Okta Role Manager Build Status Coverage Status Godoc

Okta Role Manager is the Okta role manager for Casbin. With this library, Casbin can load role hierarchy (user-role mapping) from Okta or save role hierarchy to it (NOT Implemented).

Installation

go get github.com/casbin/okta-role-manager

Simple Example

package main

import (
	"github.com/casbin/casbin"
	"github.com/casbin/okta-role-manager"
)

func main() {
	// This role manager dose not rely on Casbin policy. So we should not
	// specify grouping policy ("g" policy rules) in the .csv file.
	e := casbin.NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv")

	// Use our role manager.
	// orgName is your organization name.
	// apiToken is the token you created in the Admin portal.
	// For example, if your domain name is like: dev-123456.oktapreview.com,
	// then your orgName is dev-123456, isProductionOrPreview is false.
	// If your domain name is like: company_name.okta.com, then your orgName
	// is company_name, isProductionOrPreview is true.
	rm := oktarolemanager.NewRoleManager("dev-000000", "your_api_token", false)
	e.SetRoleManager(rm)

	// If our role manager relies on Casbin policy (like reading "g"
	// policy rules), then we have to set the role manager before loading
	// policy.
	//
	// Otherwise, we can set the role manager at any time, because role
	// manager has nothing to do with the adapter.
	e.LoadPolicy()
	
	// Check the permission.
	// Casbin's subject (user) name uses the Okta user's login field (aka Email address).
	// Casbin's role name uses the Okta group's name field (like "Admin", "Everyone").
	e.Enforce("alice@test.com", "data1", "read")
}

Getting Help

License

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoleManager

func NewRoleManager(oktaDomain string, apiToken string, isProduction bool) rbac.RoleManager

NewRoleManager is the constructor of an Okta RoleManager instance. oktaDomain is the domain for your organization on Okta. If https://dev-123456.okta.com is your org URL, then dev-17237792.okta.com is oktaDomain. apiToken is the token you created in the Admin portal.

Types

type RoleManager

type RoleManager struct {
	// contains filtered or unexported fields
}
func (rm RoleManager) AddLink(name1 string, name2 string, domain ...string) error

AddLink adds the inheritance link between role: name1 and role: name2. domain is not used.

func (RoleManager) BuildRelationship

func (rm RoleManager) BuildRelationship(name1, name2 string, domain ...string) error

BuildRelationship is deprecated.

func (RoleManager) Clear

func (rm RoleManager) Clear() error

Clear clears all stored data and resets the role manager to the initial state.

func (rm RoleManager) DeleteLink(name1 string, name2 string, domain ...string) error

DeleteLink deletes the inheritance link between role: name1 and role: name2. domain is not used.

func (RoleManager) GetAllDomains

func (rm RoleManager) GetAllDomains() ([]string, error)

func (RoleManager) GetDomains

func (rm RoleManager) GetDomains(name string) ([]string, error)

func (RoleManager) GetRoles

func (rm RoleManager) GetRoles(name string, domain ...string) ([]string, error)

GetRoles gets the roles that a subject inherits. domain is not used.

func (RoleManager) GetUsers

func (rm RoleManager) GetUsers(name string, domain ...string) ([]string, error)

GetUsers gets the users that inherits a subject. domain is not used.

func (rm RoleManager) HasLink(name1 string, name2 string, domain ...string) (bool, error)

HasLink determines whether role: name1 inherits role: name2. domain is not used.

func (RoleManager) PrintRoles

func (rm RoleManager) PrintRoles() error

PrintRoles prints all the roles to log.

func (RoleManager) SetLogger

func (rm RoleManager) SetLogger(logger log.Logger)

Jump to

Keyboard shortcuts

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