groupmembership

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package groupmembership synchronises email addresses to groups within an Azure AD tenancy.

Requirements

In order to synchronise group membership within Azure AD, you'll need to ensure you have an App Registration with the following API Permissions:

  • GroupMember.ReadWrite.All
  • User.ReadWrite.All

You will also need credentials for the App Registration to be configured appropriately in the environment using one of the default authentication mechanisms.

Index

Examples

Constants

View Source
const GroupName gosync.ConfigKey = "group_name"

GroupName is the name of your group within Azure AD.

Variables

View Source
var ErrNoResults = errors.New("no results found")

ErrNoResults is returned when the query resulted in no results and some were expected.

View Source
var ErrTooManyResults = errors.New("too many results in response")

ErrTooManyResults is returned when the query resulted in more results than expected.

Functions

func WithClient added in v0.14.1

func WithClient(client iClient) func(u *GroupMembership)

WithClient provides a mechanism to pass a custom client to the adapter.

Types

type GroupMembership

type GroupMembership struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

func Init

func Init(
	_ context.Context,
	config map[gosync.ConfigKey]string,
	configFns ...gosync.ConfigFn[*GroupMembership],
) (*GroupMembership, error)

Init creates a new adapter. It expects a single configuration entry. Required config:

  • groupmembership.GroupName: the name of the AD group to sync members to.
Example
package main

import (
	"context"
	"log"

	gosync "github.com/ovotech/go-sync"
	"github.com/ovotech/go-sync/adapters/azuread/groupmembership"
)

func main() {
	adapter, err := groupmembership.Init(context.TODO(), map[gosync.ConfigKey]string{
		groupmembership.GroupName: "My Azure AD group",
	})
	if err != nil {
		log.Fatal(err)
	}

	gosync.New(adapter)
}
Output:

func (*GroupMembership) Add

func (g *GroupMembership) Add(ctx context.Context, members []string) error

Add will add the given members to the group's member list.

func (*GroupMembership) Get

func (g *GroupMembership) Get(ctx context.Context) ([]string, error)

Get will return the membership of the group.

func (*GroupMembership) Remove

func (g *GroupMembership) Remove(ctx context.Context, members []string) error

Remove will remove the given email addresses from the group's member list.

Jump to

Keyboard shortcuts

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