Giter VIP home page Giter VIP logo

scim-keycloak-user-storage-spi's Introduction

Testing done with django-scim2 server

Initial Authentication

This plugin authenticates with a CSRF token using the java Apache HTTP client equivalent of

COOKIEJAR="cookies.txt"
rm -f $COOKIEJAR
curl -c $COOKIEJAR http://127.0.0.1:8000/admin/login/?next=/admin/ -vvv

DJANGO_TOKEN="$(grep csrftoken $COOKIEJAR | sed 's/^.*csrftoken\s*//')"
curl -b $COOKIEJAR -c $COOKIEJAR http://127.0.0.1:8000/admin/login/?next=/admin/ -H "X-CSRFToken: $DJANGO_TOKEN" -d "username=admin&password=redhat" -X POST -vvv

curl -c $COOKIEJAR -b $COOKIEJAR -X GET "http://127.0.0.1:8000/scim/v2/Users" -vvv

User functionality

  • Lookup of users ✔️
  • User Authentication ✔️
  • Search and view users in management console ✔️
    • currently only exact match search by userName
  • Add new users ✔️
  • Delete users ✔️
  • Rename User ✔️
    • Email must also be renamed (unique), or in keycloak realm settings set Login with email "Off" and Duplicate Emails "On"
  • Modify User Attributes ✔️
  • Automated/Manual Sync of SCIM users and local Keycloak users - ❌

Groups functionality

  • Current behavior: When a federated SCIM user logs in, this user's groups are added into keycloak.

Setup (bare metal local install):

  • Deploy keycloak plugin
KEYCLOAK_PATH=/path/to/keycloak/keycloak-17.0.0 sh -x ./redeploy-plugin.sh
  • Download and run keycloak

  • Login to Keycloak Admin Console (http://keycloak-server:8080)

  • Add new demo realm

  • Under User Federation -> Add the scim provider

  • In the provider settings, provide

    • a SCIM Server URL (scimserver.example.com:8000).
    • Django username and password
  • Click Save. You should see a notice that the provider has been created.

Implementation

  • This plugin performs Apache HTTP communication equivalent to the following curl commands:

  • Create user (POST)

    $ curl -b cookies.txt -X POST -d @create_scim_user_jstephenson.json "http://127.0.0.1:8000/scim/v2/Users"
* Where `create_scim_user.json` is:
~~~
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": "[email protected]",
"name":
{
    "givenName": "justin",
    "middleName": "m",
    "familyName": "stephenson"
},
"emails":
[{
    "primary": true,
    "value": "[email protected]",
    "type": "work"
}],
"displayName": "jstephenson",
"externalId": "extId",
"groups": [],
"active": true
}
~~~
  • Query users with username filter (POST):
$ curl -b cookies.txt -X POST -d @filter_testuser1.json "http://127.0.0.1:8000/scim/v2/Users/.search"
* Where `filter_testuser1.json` is
~~~
{
    "schemas": ["urn:ietf:params:scim:api:messages:2.0:SearchRequest"],
    "filter": "userName eq \"testuser1\""
}
~~~
  • Retrieve user info, where $id is the id field returned from the user creation request (ex: 6) (GET)
    $ curl -b cookies.txt http://localhost:8080/scim/v2/Users/$id
  • Retrieve complete user list:
	$ curl -b cookies.txt -X GET "http://127.0.0.1:8000/scim/v2/Users"
  • Update user -- email, firstname, lastname
  1. Search by username
  2. Get users ID
  3. PUT with complete set of user (updated) attributes
$ curl -b cookies.txt -X PUT -d @create_scim_updated_user_jstephenson.json "http://127.0.0.1:8000/scim/v2/Users/$id"
  • Where create_scim_user_updated.json is
$ {
  "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
  "userName": "[email protected]",
  "name":
  {
    "givenName": "justinnn",
    "middleName": "mmm",
    "familyName": "stephensonnn"
  },
  "emails":
  [{
    "primary": true,
    "value": "[email protected]",
    "type": "work"
  }],
  "displayName": "jstephenson",
  "externalId": "extId",
  "groups": [],
  • Delete user (DELETE)
$ curl -b cookies.txt -vvv -X DELETE http://127.0.0.1:8000/scim/v2/Users/$id

Troubleshooting

  • Check expected output with curl commands above, use tcpdump and compare with http filter.

  • Start keycloak with option --log-level=INFO,org.apache.http.wire:debug to enable http wire tracing

scim-keycloak-user-storage-spi's People

Contributors

hmlnarik avatar justin-stephenson avatar s1341 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

scim-keycloak-user-storage-spi's Issues

Support keycloak 22.0.1

It seems that this breaks when used with keycloak 22.0.1. Do we need to build against the updated keycloak?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.