grouper

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 12 Imported by: 0

README

Go Grouper

Library to interact with Grouper in Go, and a CLI app called grouperctl based on Jeremy Thornhill's awesome python script

Using GrouperCTL

Get a username and password to authenticate with, and set them in your environment variables:

export GROUPERCTL_USERNAME=01234
export GROUPERCTL_PASSWORD=my-password

Note that the username is actually a Duke unique ID, not a NetID

You can also set GROUPERCTL_STEM environment variable to a given stem if you don't want to use them in your commands.

Installation

Binaries can be downloaded from the release page, or you can use the devil-ops packaging to install the package.

Documentation

Overview

Package grouper interacts with the grouper API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBaseURL

func WithBaseURL(s string) func(*Client)

WithBaseURL sets the base URL for the grouper API

func WithDebugCurl

func WithDebugCurl() func(*Client)

WithDebugCurl will determin if the curl commands are printed when doing requests

func WithDescription added in v0.1.1

func WithDescription(s string) func(*WsRestGroupSaveLiteRequest)

WithDescription sets the description on an item

func WithDisplayExtension added in v0.1.1

func WithDisplayExtension(s string) func(*WsRestGroupSaveLiteRequest)

WithDisplayExtension sets the display extension on a new object

func WithGroupLookup added in v0.1.1

func WithGroupLookup(l WsGroupLookup) func(*WsRestGetMembersRequest)

WithGroupLookup filters the group lookup by group names

func WithGroupName added in v0.1.1

func WithGroupName[T WsRestGroupSaveLiteRequest | WsQueryFilter](s string) func(*T)

WithGroupName sets the group name on an item

func WithMemberFilter added in v0.1.1

func WithMemberFilter(m string) func(*WsRestGetMembersRequest)

WithMemberFilter sets the membership filter on a new get members request

func WithPassword

func WithPassword(s string) func(*Client)

WithPassword sets the authentication password for a grouper client

func WithQueryFilterType added in v0.1.1

func WithQueryFilterType(q string) func(*WsQueryFilter)

WithQueryFilterType sets the QueryFilterType on a new WsQueryFilter item

func WithStem added in v0.1.1

func WithStem(s string) func(*WsQueryFilter)

WithStem sets the stem on a new WsQueryFilter item

func WithUsername

func WithUsername(s string) func(*Client)

WithUsername sets the authentication username for a grouper client

Types

type ActAsSubjectLookup

type ActAsSubjectLookup struct {
	SubjectID string `json:"subjectId,omitempty"`
}

ActAsSubjectLookup defines how to act in a lookup

type AddGroupRequestWrapper

type AddGroupRequestWrapper struct {
	WsRestGroupSaveLiteRequest WsRestGroupSaveLiteRequest
}

AddGroupRequestWrapper is what we send to add a new group

type AddGroupResponseWrapper

type AddGroupResponseWrapper struct {
	WsGroupSaveLiteResult WsGroupSaveLiteResult
}

AddGroupResponseWrapper is the data we get back from the API endpoint for adding a group

type AddMemberRequestWrapper

type AddMemberRequestWrapper struct {
	WsRestAddMemberRequest WsRestAddMemberRequest
}

AddMemberRequestWrapper is the request to add a member

type AddMemberResultsResult

type AddMemberResultsResult struct {
	ResultMetadata ResultMetadata `json:"resultMetadata,omitempty"`
	WsSubject      WsSubject      `json:"wsSubject,omitempty"`
}

AddMemberResultsResult is the actual results in side the result response

type AddMemberResultsWrapper

type AddMemberResultsWrapper struct {
	WsAddMemberResults WsAddMemberResults `json:"WsAddMemberResults,omitempty"`
}

AddMemberResultsWrapper is what we get back directly from the API

type AssignPrivilegesRequestWrapper

type AssignPrivilegesRequestWrapper struct {
	WsRestAssignGrouperPrivilegesRequest WsRestAssignGrouperPrivilegesRequest
}

AssignPrivilegesRequestWrapper is what we send when assigning privileges

type AssignPrivilegesResponseWrapper

type AssignPrivilegesResponseWrapper struct {
	WsAssignGrouperPrivilegesResults WsAssignGrouperPrivilegesResults
}

AssignPrivilegesResponseWrapper is what we get back directly from the API

type Client

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

Client is the thing we use to connect and hold all the methods

func MustNew

func MustNew(opts ...func(*Client)) *Client

MustNew returns a new client or panics if there is an error

func New

func New(opts ...func(*Client)) (*Client, error)

New returns a new Client and an optional error

func (*Client) AddMember

AddMember takes a fully qualified group name and a WsRestAddMemberRequest to add members to a group

func (*Client) Create added in v0.1.1

Create adds a new group to grouper

func (*Client) Members

Members returns member information about a group

func (*Client) Privileges

Privileges returns privilege information about a group

func (*Client) Remove

Remove removes a group from grouper

func (*Client) RemoveMember

RemoveMember removes a member or members from a group

func (*Client) SearchGroups

func (c *Client) SearchGroups(filter WsQueryFilter) ([]Group, error)

SearchGroups searches groups

func (*Client) SetPrivilege

SetPrivilege adds a privilege to a given group

func (*Client) Subject added in v0.1.1

func (c *Client) Subject(by, value string) (*WsGetSubjectsResults, error)

Subject returns a subject from the API

type DeleteGroupRequestWrapper

type DeleteGroupRequestWrapper struct {
	WsRestGroupDeleteRequest WsRestGroupDeleteRequest
}

DeleteGroupRequestWrapper is the raw request sent to delete a group

type DeleteMemberRequestWrapper

type DeleteMemberRequestWrapper struct {
	WsRestDeleteMemberRequest WsRestDeleteMemberRequest
}

DeleteMemberRequestWrapper removes members from a group

type ErrorResponse

type ErrorResponse map[string]map[string]any

ErrorResponse is a helper item to normalize the error responses returned. We have to do this, because the top field returned in errors is going to be unique per request type type ErrorResponse map[string]map[string]ResultMetadata

type GetPrivilegesResponseWrapper

type GetPrivilegesResponseWrapper struct {
	WsGetGrouperPrivilegesLiteResult WsGetGrouperPrivilegesLiteResult
}

GetPrivilegesResponseWrapper is what we get back directly from the API

type GetSubjectResponseWrapper added in v0.1.1

type GetSubjectResponseWrapper struct {
	WsGetSubjectsResults WsGetSubjectsResults
}

GetSubjectResponseWrapper is exactly what the API returns when requesting a subject

type Group

type Group struct {
	Description      string `json:"description,omitempty"`
	DisplayExtension string `json:"displayExtension,omitempty"`
	DisplayName      string `json:"displayName,omitempty"`
	Enabled          string `json:"enabled,omitempty"`
	Extension        string `json:"extension,omitempty"`
	Name             string `json:"name,omitempty"`
	TypeOfGroup      string `json:"typeOfGroup,omitempty"`
	UUID             string `json:"uuid,omitempty"`
}

Group are the items returned from a group query

type GroupList added in v0.1.1

type GroupList []Group

GroupList represents multiple Group items

func (GroupList) Summary added in v0.1.1

func (g GroupList) Summary() string

Summary summarizes a GroupList

type ListPrivilegesRequestWrapper

type ListPrivilegesRequestWrapper struct {
	WsRestGetGrouperPrivilegesLiteRequest WsRestGetGrouperPrivilegesLiteRequest
}

ListPrivilegesRequestWrapper is what is sent to get a list of privileges

type MemberResultsWrapper

type MemberResultsWrapper struct {
	WsGetMembersResults WsGetMembersResults
}

MemberResultsWrapper is what is returned when looking up group members

type OwnerSubject

type OwnerSubject struct {
	ID         string `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	ResultCode string `json:"resultCode,omitempty"`
	SourceID   string `json:"sourceId,omitempty"`
	Success    string `json:"success,omitempty"`
}

OwnerSubject represents an owner I guess

type PrivilegeResult

type PrivilegeResult struct {
	Allowed       string       `json:"allowed,omitempty"`
	OwnerSubject  OwnerSubject `json:"ownerSubject,omitempty"`
	PrivilegeName string       `json:"privilegeName,omitempty"`
	PrivilegeType string       `json:"privilegeType,omitempty"`
	Revokable     string       `json:"revokable,omitempty"`
	WsGroup       WsGroup      `json:"wsGroup,omitempty"`
	WsSubject     WsSubject    `json:"wsSubject,omitempty"`
}

PrivilegeResult is the actual result for what a privilege is

type PrivilegeResultList added in v0.1.1

type PrivilegeResultList []PrivilegeResult

PrivilegeResultList represents multiple PrivilegeResult items

func (PrivilegeResultList) Summary added in v0.1.1

func (p PrivilegeResultList) Summary() string

Summary returns a summary of privilege results

type RemoveGroupResponseWrapper

type RemoveGroupResponseWrapper struct {
	WsGroupDeleteResults WsGroupDeleteResults
}

RemoveGroupResponseWrapper is what we get back directly from the api

type RemoveMemberResultsWrapper

type RemoveMemberResultsWrapper struct {
	WsDeleteMemberResults WsDeleteMemberResults
}

RemoveMemberResultsWrapper is what we get back from the API

type ResponseMetadata

type ResponseMetadata struct {
	Millis        string `json:"millis,omitempty"`
	ServerVersion string `json:"serverVersion,omitempty"`
}

ResponseMetadata is metadata returned with each response

type ResultMetadata

type ResultMetadata struct {
	ResultCode    string `json:"resultCode,omitempty"`
	ResultMessage string `json:"resultMessage,omitempty"`
	Success       string `json:"success,omitempty"`
}

ResultMetadata is result metadata

type SubjectLookup

type SubjectLookup struct {
	SubjectID string `json:"subjectId,omitempty"`
}

SubjectLookup describes the subject thing to look up

type User

type User struct {
	Name  string
	NetID string
	ID    string
}

User represents some minimal amount of information about a person

type WsAddMemberResults

type WsAddMemberResults struct {
	ResponseMetadata ResponseMetadata         `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata           `json:"resultMetadata,omitempty"`
	Results          []AddMemberResultsResult `json:"results,omitempty"`
	WsGroupAssigned  Group                    `json:"wsGroupAssigned,omitempty"`
}

WsAddMemberResults is the actual result stuff I think?

type WsAssignGrouperPrivilegesResults

type WsAssignGrouperPrivilegesResults struct {
	ResponseMetadata ResponseMetadata                         `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata                           `json:"resultMetadata,omitempty"`
	Results          []WsAssignGrouperPrivilegesResultsResult `json:"results,omitempty"`
	WsGroup          WsGroup                                  `json:"wsGroup,omitempty"`
}

WsAssignGrouperPrivilegesResults is the juicy part of the response

type WsAssignGrouperPrivilegesResultsResult

type WsAssignGrouperPrivilegesResultsResult struct {
	PrivilegeName  string         `json:"privilegeName,omitempty"`
	PrivilegeType  string         `json:"privilegeType,omitempty"`
	ResultMetadata ResultMetadata `json:"resultMetadata,omitempty"`
	WsSubject      WsSubject      `json:"wsSubject,omitempty"`
}

WsAssignGrouperPrivilegesResultsResult is the actual result item

type WsDeleteMemberResults

type WsDeleteMemberResults struct {
	ResponseMetadata ResponseMetadata              `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata                `json:"resultMetadata,omitempty"`
	Results          []WsDeleteMemberResultsResult `json:"results,omitempty"`
	WsGroup          WsGroup                       `json:"wsGroup,omitempty"`
}

WsDeleteMemberResults is the delete member results

type WsDeleteMemberResultsResult

type WsDeleteMemberResultsResult struct {
	ResultMetadata ResultMetadata `json:"resultMetadata,omitempty"`
	WsSubject      WsSubject      `json:"wsSubject,omitempty"`
}

WsDeleteMemberResultsResult are the actual result items

type WsFindGroupsResults

type WsFindGroupsResults struct {
	GroupResults     []Group          `json:"groupResults,omitempty"`
	ResponseMetadata ResponseMetadata `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata   `json:"resultMetadata,omitempty"`
}

WsFindGroupsResults are the group results with metadata from a group find

type WsFindGroupsResultsResponse

type WsFindGroupsResultsResponse struct {
	WsFindGroupsResults WsFindGroupsResults
}

WsFindGroupsResultsResponse is what we get back from the API when searching groups

type WsGetGrouperPrivilegesLiteResult

type WsGetGrouperPrivilegesLiteResult struct {
	PrivilegeResults PrivilegeResultList `json:"privilegeResults,omitempty"`
	ResponseMetadata ResponseMetadata    `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata      `json:"resultMetadata,omitempty"`
}

WsGetGrouperPrivilegesLiteResult is the juice of the response

type WsGetMembersResults

type WsGetMembersResults struct {
	ResponseMetadata      ResponseMetadata            `json:"responseMetadata,omitempty"`
	ResultMetadata        ResultMetadata              `json:"resultMetadata,omitempty"`
	Results               []WsGetMembersResultsResult `json:"results,omitempty"`
	SubjectAttributeNames []string                    `json:"subjectAttributeNames,omitempty"`
}

WsGetMembersResults are the member results

type WsGetMembersResultsResult

type WsGetMembersResultsResult struct {
	ResultMetadata ResultMetadata `json:"resultMetadata,omitempty"`
	WsGroup        WsGroup        `json:"wsGroup,omitempty"`
	WsSubjects     WsSubjectList  `json:"wsSubjects,omitempty"`
}

WsGetMembersResultsResult are where the actual results are I guess

func (WsGetMembersResultsResult) Summary added in v0.1.1

func (r WsGetMembersResultsResult) Summary() string

Summary provides a brief summary of the group results

type WsGetSubjectsResults added in v0.1.1

type WsGetSubjectsResults struct {
	ResponseMetadata ResponseMetadata `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata   `json:"resultMetadata,omitempty"`
	WsSubjects       WsSubjectList    `json:"wsSubjects,omitempty"`
}

WsGetSubjectsResults are the actual subject results

type WsGroup

type WsGroup struct {
	Description      string `json:"description,omitempty"`
	DisplayExtension string `json:"displayExtension,omitempty"`
	DisplayName      string `json:"displayName,omitempty"`
	Enabled          string `json:"enabled,omitempty"`
	Extension        string `json:"extension,omitempty"`
	Name             string `json:"name,omitempty"`
	TypeOfGroup      string `json:"typeOfGroup,omitempty"`
	UUID             string `json:"uuid,omitempty"`
}

WsGroup is a gruop

type WsGroupDeleteResults

type WsGroupDeleteResults struct {
	ResponseMetadata ResponseMetadata             `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata               `json:"resultMetadata,omitempty"`
	Results          []WsGroupDeleteResultsResult `json:"results,omitempty"`
}

WsGroupDeleteResults is the actual results

type WsGroupDeleteResultsResult

type WsGroupDeleteResultsResult struct {
	ResultMetadata ResultMetadata `json:"resultMetadata,omitempty"`
	WsGroup        WsGroup        `json:"wsGroup,omitempty"`
}

WsGroupDeleteResultsResult is the actual result item

type WsGroupList added in v0.1.1

type WsGroupList []WsGroup

WsGroupList represents multiple WsGroup items

func (WsGroupList) Summary added in v0.1.1

func (w WsGroupList) Summary() string

Summary returns a summary of a given WsGroupList

type WsGroupLookup

type WsGroupLookup struct {
	GroupName string `json:"groupName,omitempty"`
}

WsGroupLookup is an item returned from a group lookup

type WsGroupSaveLiteResult

type WsGroupSaveLiteResult struct {
	ResponseMetadata ResponseMetadata `json:"responseMetadata,omitempty"`
	ResultMetadata   ResultMetadata   `json:"resultMetadata,omitempty"`
	WsGroup          WsGroup          `json:"wsGroup,omitempty"`
}

WsGroupSaveLiteResult the juicy part of the response

type WsQueryFilter

type WsQueryFilter struct {
	GroupName       string `json:"groupName,omitempty"`
	QueryFilterType string `json:"queryFilterType,omitempty"`
	StemName        string `json:"stemName,omitempty"`
}

WsQueryFilter is for the actual query filter

func NewQueryFilter added in v0.1.1

func NewQueryFilter(opts ...func(*WsQueryFilter)) *WsQueryFilter

NewQueryFilter returns a new WsQueryFilter item with functional options

type WsRestAddMemberRequest

type WsRestAddMemberRequest struct {
	ReplaceAllExisting string          `json:"replaceAllExisting,omitempty"`
	SubjectLookups     []SubjectLookup `json:"subjectLookups,omitempty"`
}

WsRestAddMemberRequest is the actual request data

type WsRestAssignGrouperPrivilegesRequest

type WsRestAssignGrouperPrivilegesRequest struct {
	Allowed            string          `json:"allowed,omitempty"`
	PrivilegeNames     []string        `json:"privilegeNames,omitempty"`
	PrivilegeType      string          `json:"privilegeType,omitempty"`
	ReplaceAllExisting string          `json:"replaceAllExisting,omitempty"`
	WsGroupLookup      WsGroupLookup   `json:"wsGroupLookup,omitempty"`
	WsSubjectLookups   []SubjectLookup `json:"wsSubjectLookups,omitempty"`
}

WsRestAssignGrouperPrivilegesRequest is the juicy part of the request

type WsRestDeleteMemberRequest

type WsRestDeleteMemberRequest struct {
	ReplaceAllExisting string          `json:"replaceAllExisting,omitempty"`
	SubjectLookups     []SubjectLookup `json:"subjectLookups,omitempty"`
}

WsRestDeleteMemberRequest is the actual request data

type WsRestFindGroupsRequest

type WsRestFindGroupsRequest struct {
	ActAsSubjectLookup *ActAsSubjectLookup `json:"subjectId,omitempty"`
	WsQueryFilter      WsQueryFilter       `json:"wsQueryFilter,omitempty"`
}

WsRestFindGroupsRequest handles the API for the request

type WsRestFindGroupsRequestWrapper

type WsRestFindGroupsRequestWrapper struct {
	WsRestFindGroupsRequest WsRestFindGroupsRequest `json:"WsRestFindGroupsRequest,omitempty"`
}

WsRestFindGroupsRequestWrapper is what is sent to find groups

type WsRestGetGrouperPrivilegesLiteRequest

type WsRestGetGrouperPrivilegesLiteRequest struct {
	GroupName     string `json:"groupName,omitempty"`
	PrivilegeName string `json:"privilegeName,omitempty"`
	PrivilegeType string `json:"privilegeType,omitempty"`
}

WsRestGetGrouperPrivilegesLiteRequest is the actual juicy part of the request

type WsRestGetMembersRequest

type WsRestGetMembersRequest struct {
	IncludeSubjectDetail  string          `json:"includeSubjectDetail,omitempty"`
	MemberFilter          string          `json:"memberFilter,omitempty"`
	SubjectAttributeNames []string        `json:"subjectAttributeNames,omitempty"`
	WsGroupLookups        []WsGroupLookup `json:"wsGroupLookups,omitempty"`
}

WsRestGetMembersRequest returns the member request info

func NewGetMembersRequest added in v0.1.1

func NewGetMembersRequest(opts ...func(*WsRestGetMembersRequest)) *WsRestGetMembersRequest

NewGetMembersRequest returns a new member request item using functional options

type WsRestGetMembersRequestWrapper

type WsRestGetMembersRequestWrapper struct {
	WsRestGetMembersRequest WsRestGetMembersRequest `json:"WsRestGetMembersRequest,omitempty"`
}

WsRestGetMembersRequestWrapper wraps the request for members

type WsRestGroupDeleteRequest

type WsRestGroupDeleteRequest struct {
	WsGroupLookups []WsGroupLookup `json:"wsGroupLookups,omitempty"`
}

WsRestGroupDeleteRequest is the actual request for the delete

func NewDeleteGroupRequest added in v0.1.1

func NewDeleteGroupRequest(groups ...string) WsRestGroupDeleteRequest

NewDeleteGroupRequest deletes creates a new delete request for the given VMs Pass in a list of fully qualified group names, and they will be deleted

type WsRestGroupSaveLiteRequest

type WsRestGroupSaveLiteRequest struct {
	Description      string `json:"description,omitempty"`
	DisplayExtension string `json:"displayExtension,omitempty"`
	GroupName        string `json:"groupName,omitempty"`
}

WsRestGroupSaveLiteRequest is the actual request for a new group

func NewCreateGroupRequest added in v0.1.1

func NewCreateGroupRequest(opts ...func(*WsRestGroupSaveLiteRequest)) *WsRestGroupSaveLiteRequest

NewCreateGroupRequest returns a WsRestGroupSaveLiteRequest with information on how to create a group

type WsSubject

type WsSubject struct {
	AttributeValues []string `json:"attributeValues,omitempty"`
	ID              string   `json:"id,omitempty"`
	MemberID        string   `json:"memberId,omitempty"`
	Name            string   `json:"name,omitempty"`
	ResultCode      string   `json:"resultCode,omitempty"`
	SourceID        string   `json:"sourceId,omitempty"`
	Success         string   `json:"success,omitempty"`
}

WsSubject is the member result

func (WsSubject) MarshalLine added in v0.1.1

func (s WsSubject) MarshalLine() string

MarshalLine returns the subject in a simple single line format, similar to Jeremy's awesome python script

type WsSubjectList added in v0.1.1

type WsSubjectList []WsSubject

WsSubjectList represents multiple WsSubject items

func (WsSubjectList) Summary added in v0.1.1

func (w WsSubjectList) Summary() string

Summary returns a summary of a given WsGroupList

Directories

Path Synopsis
cmd
grouperctl
Package main is the main executable for the CLI
Package main is the main executable for the CLI
grouperctl/cmd
Package cmd holds all the cli stuff
Package cmd holds all the cli stuff
examples

Jump to

Keyboard shortcuts

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