scim

package module
v0.0.0-...-038864c Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

README

img License


Client Go pour approvisionnement SCIM du service AWS Single Sign-On

Client SCIM extrait du projet https://github.com/awslabs/ssosync pour importation en module Go.

1.0 Objectifs

Le service AWS Single Sign-On expose un API d'approvisionnement d'usagers basé sur le standard SCIM. Ce module Go implémente un client permettant d'exploiter cet API.

2.0 Installation

go get github.com/CQEN-QDCE/aws-sso-scim-goclient

3.0 Exemple

import (
	"fmt"
	scim "github.com/CQEN-QDCE/aws-sso-scim-goclient"
)

const SCIM_ENDPOINT = "*YOUR_ENDPOINT*"
const SCIM_TOKEN = "*YOUR_TOKEN*"

awsClient, err := scim.NewClient(
    &http.Client{},
    &scim.Config{
        Endpoint: SCIM_ENDPOINT,
        Token:    SCIM_TOKEN,
    })

if err != nil {
    //return err
}

listUsers, err := awsClient.GetUsers()

if err != nil {
    //return err
}

for _, user := range listUsers {
    println(user.Username)
}

4.0 Licence

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound      = errors.New("user not found")
	ErrGroupNotFound     = errors.New("group not found")
	ErrNoGroupsFound     = errors.New("no groups found")
	ErrUserNotSpecified  = errors.New("user not specified")
	ErrGroupNotSpecified = errors.New("group not specified")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	AddUserToGroup(*User, *Group) error
	CreateGroup(*Group) (*Group, error)
	UpdateGroup(*Group) error
	CreateUser(*User) (*User, error)
	DeleteGroup(*Group) error
	DeleteUser(*User) error
	FindGroupByDisplayName(string) (*Group, error)
	FindUserByEmail(string) (*User, error)
	FindUserByID(string) (*User, error)
	GetUsers() ([]*User, error)
	GetGroupMembers(*Group) ([]*User, error)
	IsUserInGroup(*User, *Group) (bool, error)
	GetGroups() ([]*Group, error)
	UpdateUser(*User) (*User, error)
	RemoveUserFromGroup(*User, *Group) error
}

Client represents an interface of methods used to communicate with AWS SSO

func NewClient

func NewClient(c HttpClient, config *Config) (Client, error)

NewClient creates a new client to talk with AWS SSO's SCIM endpoint. It requires a http.Client{} as well as the URL and bearer token from the console. If the URL is not parsable, an error will be thrown.

type Config

type Config struct {
	Endpoint string
	Token    string
}

Config specifes the configuration needed for AWS SSO SCIM

func ReadConfigFromFile

func ReadConfigFromFile(path string) (*Config, error)

ReadConfigFromFile will read a TOML file into the Config Struct

type Group

type Group struct {
	ID          string   `json:"id,omitempty"`
	Schemas     []string `json:"schemas"`
	DisplayName string   `json:"displayName"`
	Members     []string `json:"members"`
}

Group represents a Group in AWS SSO

func NewGroup

func NewGroup(groupName string) *Group

NewGroup creates an object representing a group with the given name

type GroupFilterResults

type GroupFilterResults struct {
	Schemas      []string `json:"schemas"`
	TotalResults int      `json:"totalResults"`
	ItemsPerPage int      `json:"itemsPerPage"`
	StartIndex   int      `json:"startIndex"`
	Resources    []Group  `json:"Resources"`
}

GroupFilterResults represents filtered results when we search for groups or List all groups

type GroupMemberChange

type GroupMemberChange struct {
	Schemas    []string                     `json:"schemas"`
	Operations []GroupMemberChangeOperation `json:"Operations"`
}

GroupMemberChange represents a change operation for a group

type GroupMemberChangeMember

type GroupMemberChangeMember struct {
	Value string `json:"value"`
}

GroupMemberChangeMember is a value needed for the ID of the member to add/remove

type GroupMemberChangeOperation

type GroupMemberChangeOperation struct {
	Operation string                    `json:"op"`
	Path      string                    `json:"path"`
	Members   []GroupMemberChangeMember `json:"value"`
}

GroupMemberChangeOperation details the operation to take place on a group

type GroupReplace

type GroupReplace struct {
	Schemas    []string                `json:"schemas"`
	Operations []GroupReplaceOperation `json:"Operations"`
}

GroupReplace structs for Group replace patch operation

type GroupReplaceOperation

type GroupReplaceOperation struct {
	Operation string            `json:"op"`
	Group     GroupReplaceValue `json:"value"`
}

type GroupReplaceValue

type GroupReplaceValue struct {
	GroupId     string `json:"id"`
	DisplayName string `json:"displayName"`
}

type HttpClient

type HttpClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpClient is a generic HTTP Do interface

type OperationType

type OperationType string

OperationType handle patch operations for add/remove groupe members

const (
	// OperationAdd is the add operation for a patch
	OperationAdd OperationType = "add"

	// OperationRemove is the remove operation for a patch
	OperationRemove OperationType = "remove"

	// OperationRemove is the replace operation for a patch
	OperationReplace OperationType = "replace"
)

type User

type User struct {
	ID       string   `json:"id,omitempty"`
	Schemas  []string `json:"schemas"`
	Username string   `json:"userName"`
	Name     struct {
		FamilyName string `json:"familyName"`
		GivenName  string `json:"givenName"`
	} `json:"name"`
	DisplayName string        `json:"displayName"`
	Active      bool          `json:"active"`
	Emails      []UserEmail   `json:"emails"`
	Addresses   []UserAddress `json:"addresses"`
}

User represents a User in AWS SSO

func NewUser

func NewUser(firstName string, lastName string, email string, active bool) *User

NewUser creates a user object representing a user with the given details.

func UpdateUser

func UpdateUser(id string, firstName string, lastName string, email string, active bool) *User

UpdateUser updates a user object representing a user with the given details.

type UserAddress

type UserAddress struct {
	Type string `json:"type"`
}

UserAddress represents address values of users

type UserEmail

type UserEmail struct {
	Value   string `json:"value"`
	Type    string `json:"type"`
	Primary bool   `json:"primary"`
}

UserEmail represents a user email address

type UserFilterResults

type UserFilterResults struct {
	Schemas      []string `json:"schemas"`
	TotalResults int      `json:"totalResults"`
	ItemsPerPage int      `json:"itemsPerPage"`
	StartIndex   int      `json:"startIndex"`
	Resources    []User   `json:"Resources"`
}

UserFilterResults represents filtered results when we search for users or List all users

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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