Compare commits
1 commit
main
...
experiment
Author | SHA1 | Date | |
---|---|---|---|
cfd5f47698 |
6 changed files with 182 additions and 0 deletions
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
|
||||||
|
// Pointez pour afficher la description des attributs existants.
|
||||||
|
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Package",
|
||||||
|
"type": "go",
|
||||||
|
"request": "launch",
|
||||||
|
"mode": "auto",
|
||||||
|
"program": "${workspaceFolder}/cmd/liiibre-sp/main.go"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
102
cmd/liiibre-sp/main.go
Normal file
102
cmd/liiibre-sp/main.go
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/elimity-com/scim"
|
||||||
|
"github.com/elimity-com/scim/optional"
|
||||||
|
"github.com/elimity-com/scim/schema"
|
||||||
|
)
|
||||||
|
|
||||||
|
type testResourceHandler struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
config := scim.ServiceProviderConfig{
|
||||||
|
DocumentationURI: optional.NewString("localhost:8282"),
|
||||||
|
}
|
||||||
|
|
||||||
|
// schema := schema.Schema{
|
||||||
|
// ID: schema.UserSchema,
|
||||||
|
// Name: optional.NewString("User"),
|
||||||
|
// Description: optional.NewString("User Account"),
|
||||||
|
// Attributes: []schema.CoreAttribute{
|
||||||
|
// schema.SimpleCoreAttribute(schema.SimpleStringParams(schema.StringParams{
|
||||||
|
// Name: "userName",
|
||||||
|
// Required: true,
|
||||||
|
// Uniqueness: schema.AttributeUniquenessServer(),
|
||||||
|
// })),
|
||||||
|
// },
|
||||||
|
// }
|
||||||
|
|
||||||
|
resourceTypes := []scim.ResourceType{
|
||||||
|
{
|
||||||
|
ID: optional.NewString("User"),
|
||||||
|
Name: "User",
|
||||||
|
Endpoint: "/Users",
|
||||||
|
Description: optional.NewString("User Account"),
|
||||||
|
Schema: schema.CoreUserSchema(),
|
||||||
|
Handler: testResourceHandler{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: optional.NewString("Group"),
|
||||||
|
Name: "Group",
|
||||||
|
Endpoint: "/Groups",
|
||||||
|
Description: optional.NewString("Group"),
|
||||||
|
Schema: schema.CoreGroupSchema(),
|
||||||
|
Handler: testResourceHandler{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
server := scim.Server{
|
||||||
|
Config: config,
|
||||||
|
ResourceTypes: resourceTypes,
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Handle("/", server)
|
||||||
|
log.Fatal(http.ListenAndServe(":8282", nil))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) Create(r *http.Request, attributes scim.ResourceAttributes) (scim.Resource, error) {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
id := fmt.Sprintf("%04d", rand.Intn(9999))
|
||||||
|
|
||||||
|
// now := time.Now()
|
||||||
|
|
||||||
|
return scim.Resource{
|
||||||
|
ID: id,
|
||||||
|
ExternalID: optional.NewString(attributes["externalId"].(string)),
|
||||||
|
Attributes: attributes,
|
||||||
|
Meta: scim.Meta{
|
||||||
|
// Created: &now,
|
||||||
|
// LastModified: &now,
|
||||||
|
Version: fmt.Sprintf("v%s", id),
|
||||||
|
},
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) Get(r *http.Request, id string) (scim.Resource, error) {
|
||||||
|
return scim.Resource{}, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) GetAll(r *http.Request, params scim.ListRequestParams) (scim.Page, error) {
|
||||||
|
return scim.Page{}, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) Replace(r *http.Request, id string, attributes scim.ResourceAttributes) (scim.Resource, error) {
|
||||||
|
return scim.Resource{}, errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) Delete(r *http.Request, id string) error {
|
||||||
|
return errors.New("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h testResourceHandler) Patch(r *http.Request, id string, operations []scim.PatchOperation) (scim.Resource, error) {
|
||||||
|
return scim.Resource{}, errors.New("not implemented")
|
||||||
|
}
|
29
docker-compose.yml
Normal file
29
docker-compose.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: keycloak
|
||||||
|
POSTGRES_PASSWORD: keycloak
|
||||||
|
keycloak:
|
||||||
|
build:
|
||||||
|
context: keycloak
|
||||||
|
environment:
|
||||||
|
DB_VENDOR: POSTGRES
|
||||||
|
DB_ADDR: postgres
|
||||||
|
DB_DATABASE: keycloak
|
||||||
|
DB_USER: keycloak
|
||||||
|
DB_SCHEMA: public
|
||||||
|
DB_PASSWORD: keycloak
|
||||||
|
KEYCLOAK_USER: admin
|
||||||
|
KEYCLOAK_PASSWORD: admin
|
||||||
|
ports:
|
||||||
|
- 8080:8080
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
13
go.mod
Normal file
13
go.mod
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module lab.libreho.st/libre.sh/scim
|
||||||
|
|
||||||
|
go 1.17
|
||||||
|
|
||||||
|
require github.com/elimity-com/scim v0.0.0-20211119105057-007f1a2691f0
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/di-wu/parser v0.2.2 // indirect
|
||||||
|
github.com/di-wu/xsd-datetime v1.0.0 // indirect
|
||||||
|
github.com/scim2/filter-parser/v2 v2.2.0 // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
// replace github.com/elimity-com/scim => /home/hougo/git/hrenard/scim
|
8
go.sum
Normal file
8
go.sum
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
github.com/di-wu/parser v0.2.2 h1:I9oHJ8spBXOeL7Wps0ffkFFFiXJf/pk7NX9lcAMqRMU=
|
||||||
|
github.com/di-wu/parser v0.2.2/go.mod h1:SLp58pW6WamdmznrVRrw2NTyn4wAvT9rrEFynKX7nYo=
|
||||||
|
github.com/di-wu/xsd-datetime v1.0.0 h1:vZoGNkbzpBNoc+JyfVLEbutNDNydYV8XwHeV7eUJoxI=
|
||||||
|
github.com/di-wu/xsd-datetime v1.0.0/go.mod h1:i3iEhrP3WchwseOBeIdW/zxeoleXTOzx1WyDXgdmOww=
|
||||||
|
github.com/elimity-com/scim v0.0.0-20211119105057-007f1a2691f0 h1:/26/OeOlwid0okzLB3ZN0p/wgzxOmQhGnH0VYPhRBVU=
|
||||||
|
github.com/elimity-com/scim v0.0.0-20211119105057-007f1a2691f0/go.mod h1:JkjcmqbLW+khwt2fmBPJFBhx2zGZ8XobRZ+O0VhlwWo=
|
||||||
|
github.com/scim2/filter-parser/v2 v2.2.0 h1:QGadEcsmypxg8gYChRSM2j1edLyE/2j72j+hdmI4BJM=
|
||||||
|
github.com/scim2/filter-parser/v2 v2.2.0/go.mod h1:jWnkDToqX/Y0ugz0P5VvpVEUKcWcyHHj+X+je9ce5JA=
|
15
keycloak/Dockerfile
Normal file
15
keycloak/Dockerfile
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
FROM maven:3-openjdk-11 as base
|
||||||
|
|
||||||
|
# RUN apt-get update && apt-get install -y git maven
|
||||||
|
|
||||||
|
RUN git clone https://github.com/suvera/keycloak-scim2-storage.git
|
||||||
|
|
||||||
|
WORKDIR /keycloak-scim2-storage
|
||||||
|
|
||||||
|
RUN mvn clean install
|
||||||
|
|
||||||
|
FROM docker.io/jboss/keycloak:16.1.0
|
||||||
|
|
||||||
|
COPY --from=base /keycloak-scim2-storage/target/suvera-keycloak-scim2-outbound-provisioning-jar-with-dependencies.jar /opt/jboss/keycloak/standalone/deployments/
|
||||||
|
|
||||||
|
# RUN curl https://github.com/Captain-P-Goldfish/scim-for-keycloak/releases/download/kc-16-b2/scim-for-keycloak-kc-16-b2.ear -o /opt/jboss/keycloak/standalone/deployments/scim-for-keycloak-kc-16-b2.ear
|
Reference in a new issue