Getting started
Ce contenu n’est pas encore disponible dans votre langue.
This guide walks through the minimal setup to get a SCIM 2.0 server running. It uses the in-memory backend, which is suitable for development and testing.
1. Create a schema registry
Section titled “1. Create a schema registry”The registry holds schema definitions and resource type registrations. RegisterDefaults adds User, Group, and EnterpriseUser.
import "github.com/cerberauth/scimply/schema"
reg := schema.NewRegistry()reg.RegisterDefaults()2. Create the server
Section titled “2. Create the server”import ( "github.com/cerberauth/scimply/server" "github.com/cerberauth/scimply/store")
srv, err := server.New( server.WithStore(store.NewMemoryStore()), server.WithSchemaRegistry(reg), server.WithBasePath("/scim/v2"), server.WithBearerTokenAuth(func(token string) (bool, error) { return token == "my-secret-token", nil }),)if err != nil { log.Fatal(err)}server.New returns an http.Handler. Mount it directly with http.ListenAndServe or attach it to any existing mux.
3. Serve
Section titled “3. Serve”log.Fatal(http.ListenAndServe(":8080", srv))4. Try it
Section titled “4. Try it”Create a user:
curl -X POST http://localhost:8080/scim/v2/Users \ -H "Authorization: Bearer my-secret-token" \ -H "Content-Type: application/scim+json" \ -d '{ "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"], "userName": "bjensen", "name": { "formatted": "Ms. Barbara J Jensen" }, "emails": [{ "value": "bjensen@example.com", "primary": true }], "active": true }'List users:
curl http://localhost:8080/scim/v2/Users \ -H "Authorization: Bearer my-secret-token"Inspect server capabilities:
curl http://localhost:8080/scim/v2/ServiceProviderConfig \ -H "Authorization: Bearer my-secret-token"Next steps
Section titled “Next steps”- Filtering — query users with RFC 7644 filter expressions
- PATCH operations — partial resource updates
- Custom store — connect a real database