scim

package module
v0.0.0-...-f825106 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 0 Imported by: 1

README

scim

Go Reference

SCIM tools for Go (Work In Progress)

  • server - SCIM server
  • client - SCIM client
  • resource - Definition of SCIM resource types
  • filter - Basic SCIM filter parsing, with a simple SQL generator

SYNOPSIS

package examples_test

import (
  "context"
  "fmt"
  "net/http/httptest"

  "github.com/cybozu-go/scim/server"
)

func ExampleClient_UserCreate() {
  srv := httptest.NewServer(server.MustNewServer(NewMockBackend()))
  defer srv.Close()

  // Create a SCIM client: this is wrapped in another function call
  // to accomodate for debug tracing, but you can replace it with
  // a client.New() call
  cl := NewClient(srv.URL)

  user, err := cl.User().Create().
    DisplayName(`Daisuke Maki`).
    ExternalID(`lestrrat`).
    UserName(`lestrrat`).
    Do(context.TODO())
  if err != nil {
    fmt.Printf("failed to create user: %s", err)
  }

  _ = user

  // OUTPUT:
  //
}

source: ./examples/client_user_create_example_test.go

TODO

  • Finish implementing sample server
    • Probably move it to github.com/cybozu-go/scim-ent
  • Implement check in CI to diff against generated code
  • Streamline code generation

Code Generation

go generate ./resource

Generates code in resource, sample/ent/schema, and sample. If you made any changes that result in changes to code under sample/ent/schema, you need to run go generate ./sample as well.

Source file is tools/cmd/genresources/objects.yml

go generate ./sample

Generates code for ent, based on files under sample/ent/schema. This generates code from ent code, and thus have not source file.

go generate ./client

Generates client code. Requires some synchronization between resource.

Source file is tools/cmd/genclient/calls.yml

go generate ./filter

Generates filter parser code from filter/parser.go.y support objects.

Source file is tools/cmd/genfilter/objects.yml

go generate .

Generates options, as well as run all of go generate for resource, sample, client, and filer

Source files are located in various places, under the name options.yml

Documentation

Overview

Package scim contains SCIM resource definitions, SCIM client implementation, and server-side shim for a simplistic SCIM service.

`resource` Directory

Directory `resource` contains resource definitions, such as `resource.User`, and `resource.Group`.

The resource objects are considered immutable once initialized. Use the corresponding builder objects to create new instances.

Each resource object is implemented such that when/if the payload from the wire contains extra fields, those fields can safely be unmarshaled as well, allowing you to define extra fields, extra sub-resource types, extensions to existing SCIM resources via schema-qualified fields, etc.

`client` Directory

Directory `client` contains a SCIM client.

The structure is loosely similar to Google Cloud Go SDK. At the top level there is a `Client` object. The client has `Service` objects that group individual `Call` objects.

The `Service` object is only a logical grouping of `Call` objects.

Each `Call` object encapsulates an operation to an SCIM operation endpoint. `Call` objects are created by executing methods on the parent `Service` object. These method may require parameters: these exist because these parameters are required fields in the SCIM operation.

All other optional parameters are passed via method calls on the `Call` object, in a builder-pattern.

When the `Call` object is ready, invoke the `Do` method, which will issue an HTTP request to the endpoint, do the necessary conversions and return the response or an error.

Customizing the HTTP request

When/if you want to control the behavior of your HTTP client, you can pass your customized HTTP client to the `client.New` contstructor:

customClient := ... // *http.Client object, or anything that satisfies client.HTTPClient
cl := client.New(url, client.WithClient(customClient))

Directories

Path Synopsis
examples module
internal/fparser
Code generated by goyacc -l -o internal/fparser/parser.go -v filter_parser.output internal/fparser/parser.go.y.
Code generated by goyacc -l -o internal/fparser/parser.go -v filter_parser.output internal/fparser/parser.go.y.
internal/pparser
Code generated by goyacc -l -o internal/pparser/parser.go -v patch_parser.output internal/pparser/parser.go.y.
Code generated by goyacc -l -o internal/pparser/parser.go -v patch_parser.output internal/pparser/parser.go.y.
internal/scanner
This file is based on https://github.com/hiyosi/filter/blob/master/lexer.go
This file is based on https://github.com/hiyosi/filter/blob/master/lexer.go
Generated by "sketch" utility.
Generated by "sketch" utility.
Package schema contains the schema for SCIM resources.
Package schema contains the schema for SCIM resources.
tools
cmd/genclient Module
schema Module

Jump to

Keyboard shortcuts

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