scimpatch

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

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 6 Imported by: 0

README

scim-patch

Go Reference

Go implementation of SCIM 2.0 Patch operations.

[!CAUTION] It has not been stable. Not ready for production use.

Overview

The specification of SCIM 2.0 Patch operations is broad, and absorbing the differences for each IdP is also challenging. Therefore, this library aims to comprehensively handle "schema manipulation via Patch".

Since this does not directly manipulate the application's data, overall processing and data storage may become redundant. However, instead of that, you only need to consider mapping between the SCIM schema and the schema used in your application, helping to reduce tight coupling.

Additionally, this library depends on the following SCIM-related implementations for handling Schema and filters:

Expected Usage Example

The following issue is relevant, and we aim to implement it to be usable in a form similar to this example: https://github.com/elimity-com/scim/issues/171

For an example of usage in the current implementation, please refer to example.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operator

type Operator interface {
	Direct(scopedMap map[string]interface{}, scopedAttr string, value interface{}) (map[string]interface{}, bool)
	ByValueForItem(scopedSlice []interface{}, value interface{}) ([]interface{}, bool)
	ByValueExpressionForItem(scopedMaps []map[string]interface{}, expr filter.Expression, value interface{}) ([]map[string]interface{}, bool)
	ByValueExpressionForAttribute(scopedMaps []map[string]interface{}, expr filter.Expression, subAttr string, value interface{}) ([]map[string]interface{}, bool)
}

Operator は Patch Operation の各操作のドメインとなるインターフェースです。 Direct は map とその map 内で更新対象となる属性と更新後の値を受け取って更新後のmapと変更有無を返却します この関数のみ、pathが未指定の場合でも利用されます ByValueForItem は path が指定されているときに、MultiValued な属性名が指定されたとき対象のスライスと指定された値を受け取って、更新後のスライスと変更有無を返却します。 ByValueExpressionForItem は 対象の属性が、MultiValuedComplexAttribute で path にて valFilter が指定されているときにそれを受けとって更新後のスライスと変更有無を返却します。 ByValueExpressionForAttribute は 対象の属性が、MultiValuedComplexAttribute で path にて valFilter と subAttr が指定されているときにそれを受けとって更新後のスライスと変更有無を返却します。

type Patcher

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

func NewPatcher

func NewPatcher(
	s schema.Schema,
	extentions []schema.Schema,
	opts *PatcherOpts,
) *Patcher

NewPatcher は Patcher の実態を取得します。

func (*Patcher) Apply

func (p *Patcher) Apply(op scim.PatchOperation, data map[string]interface{}) (map[string]interface{}, bool, error)

Apply は RFC7644 3.5.2. Modifying with PATCH の実装です。 data に op が適用された ResourceAttributes と実際に適用されたかどうかの真偽値を返却します。 see. https://datatracker.ietf.org/doc/html/rfc7644#section-3.5.2

type PatcherOpts

type PatcherOpts struct {
	Additionnar *Operator
	Replacer    *Operator
	Remover     *Operator
}

PatcherOpts を利用することで Pathcerが利用する各操作の Operator を上書きすることができます。 指定しない場合はパッケージデフォルトで実装されている Operator が利用されます。

Jump to

Keyboard shortcuts

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