Giter Club home page Giter Club logo

fiware-keystone-scim's Introduction

Keystone SCIM extension

FIWARE Security License: Apache 2.0
Status

Keystone SCIM is an OpenStack Keystone extension that enables the management of User, Groups and Roles using SCIM v1.1 standard. As any Keystone extension, it's designed to be installed on top of an existing Keystone installation, following Keystone recommendations for extensions.

A brief description of SCIM:

The SCIM standard was created to simplify user management in the cloud by defining a schema for representing users and groups and a REST API for all the necessary CRUD operations.

SCIM User and Group API are a direct translation of Keystone User and Group APIs, they even share the same security policies (with the exact same names).

On the other hand, SCIM Roles are slightly different from Keystone Roles: now SCIM Roles are domain aware. The extension implementation does not make any modification to the underlying database, in order to maintain backward compatibility with Keystone Roles API.

SCIM Roles are implemented on top of Keystone Roles, prefixing the domain id to the role name. You may argue that this is a kinda of a hack, and the relational integrity is not maintained. And that's true, but in this way the database schema is not modified and thus the Keystone Roles API can interact with SCIM Roles out-of-the-box.

Installing

RPM installing on RDO Openstack

Installing from RPM is pretty straightforward:

rpm -Uvh keystone-scim-*.noarch.rpm

Once installed you can fine-tune the permissions (out-of-the box the installation configures the permissions to rule:admin_required for Role management; User and Group management reuses the Keystone permissions).

Restart Keystone server:

sudo service openstack-keystone restart

TGZ installaton

Uncompress tgz file plugin into python site-packages directory. Make a soft link from keystone contrib directory to that directory. For more details see [RPM spec steps ][./keystone-scim.spec).

Install Keystone

There is a complete guide to install step by step keystone for development purposes:

https://github.com/telefonicaid/fiware-pep-steelskin/blob/master/keystoneInstallation.md

Permissions fine tuning

As SCIM Roles are domain aware, a new set of permissions are defined, to take care of the domain.

Sample permissions:

"identity:scim_get_role": "rule:admin_required"
"identity:scim_list_roles": "rule:admin_required"
"identity:scim_create_role": "rule:admin_required"
"identity:scim_update_role": "rule:admin_required"
"identity:scim_delete_role": "rule:admin_required"
"identity:scim_get_service_provider_configs": ""
"identity:scim_get_schemas": ""

Recommended (and tested) permissions for a Keystone domain aware configuration (this config assumes that Keystone policies is configured using policy.v3cloudsample.json):

"identity:scim_delete_role": "rule:cloud_admin or rule:admin_and_matching_domain_id"
"identity:scim_update_role": "rule:cloud_admin or rule:admin_and_matching_domain_id"
"identity:scim_get_role": "rule:cloud_admin or rule:admin_and_matching_domain_id"
"identity:scim_list_roles": "rule:cloud_admin or rule:admin_and_matching_domain_id"
"identity:scim_create_role": "rule:cloud_admin or rule:admin_and_matching_domain_id"
"identity:scim_get_service_provider_configs": ""
"identity:scim_get_schemas": ""

Usage

SCIM extension reuses the authentication and authorization mechanisms provided by Keystone. This document assumes that the reader has previous experience with Keystone, but as a reference you can read more about the Keystone Authentication and Authorization mechanism in it's official documentation.

SCIM itself is extensively documented in Core Schema and in REST API.

Given that both Keystones Auth mechanisms and SCIM are document, this section focus on running examples, not covering the full API, but giving the reader and overview of how this extension should be used.

Creating an User:

curl http://<KEYSTONE>:5000/v3/OS-SCIM/Users \
    -s \
    -H "X-Auth-Token: <TOKEN>" \
    -H "Content-Type: application/json" \
    -d '
{
    "schemas": ["urn:scim:schemas:core:1.0",
                "urn:scim:schemas:extension:keystone:1.0"],
    "userName": "alice",
    "displayName": "Alice Smith",
    "password": "passw0rd",
    "emails": [
        {
            "value": "[email protected]"
        }
    ],
    "active": true,
    "urn:scim:schemas:extension:keystone:1.0": {
        "domain_id": "91d79dc2211d43a7985ebc27cdd146df"
    }
}'

Response:

{
  "userName": "alice",
  "displayName": "Alice Smith",
  "urn:scim:schemas:extension:keystone:1.0": {
    "domain_id": "91d79dc2211d43a7985ebc27cdd146df"
  },
  "emails": [
    {
      "value": "[email protected]"
    }
  ],
  "active": true,
  "id": "a5e8c847f7264c5a9f01a22904e3ae93",
  "schemas": [
    "urn:scim:schemas:core:1.0",
    "urn:scim:schemas:extension:keystone:1.0"
  ]
}

Listing Users, filtering by domain_id:

curl -s -X GET -H "X-Auth-Token: <TOKEN>" \
http://<KEYSTONE>:5000/v3/OS-SCIM/Users?domain_id=<DOMAIN_ID>

Response:

{
  "Resources": [
    {
      "active": true,
      "displayName": "adm1",
      "id": "19041ee7679649879ada04417753ad4d",
      "urn:scim:schemas:extension:keystone:1.0": {
        "domain_id": "91d79dc2211d43a7985ebc27cdd146df"
      }
    }
  ],
  "schemas": [
    "urn:scim:schemas:core:1.0",
    "urn:scim:schemas:extension:keystone:1.0"
  ]
}

Listing supports pagination as defined by SCIM standard, using count and startIndex query params.

Creating Role:

curl http://<KEYSTONE>:5000/v3/OS-SCIM/Roles \
    -s \
    -H "X-Auth-Token: <TOKEN>" \
    -H "Content-Type: application/json" \
    -d '
{
  "schemas": ["urn:scim:schemas:extension:keystone:1.0"],
  "name": "aRoleName",
  "domain_id": "<DOMAIN_ID>"
}'

Response:

{
  "schemas": [
    "urn:scim:schemas:extension:keystone:1.0"
  ],
  "domain_id": "91d79dc2211d43a7985ebc27cdd146df",
  "id": "c80481d244454cc7b796d4acf8625a69",
  "name": "aRoleName"
}

Building and packaging

In any Linux RPM based distribution (Centos, RH, etc) with a sane build environment (basically with rpmbuild installed), the RPM package can be built invoking the following command:

sh ./package-keystone-scim.sh

Hacking

Local development (by default using sqlite). Running a local development server is useful to test a full featured Keystone server with SCIM extension, and installation is straightforward following these steps:

Setup a virtualenv (highly recommended).

virtualenv .venv

Activate virtualenv

source .venv/bin/activate

Download dependencies

pip install -r requirements.txt
pip install -r test-requirements.txt
pip install tox

Running tests (functional and unit tests)

tox -e py27

Setting up local development server. First populate database (remember that this will use sqlite).

keystone-manage db_sync

Launch server

PYTHONPATH=.:$PYTHONPATH keystone-all --config-dir etc

Test SCIM extension

curl http://localhost:5000/v3/OS-SCIM/ServiceProviderConfigs \
    -s \
    -H "X-Auth-Token: ADMIN"

The response should look like:

{
  "bulk": {
    "maxPayloadSize": 0,
    "supported": false,
    "maxOperations": 0
  },
  "filter": {
    "supported": true,
    "maxResults": 9223372036854776000
  },
  "etag": {
    "supported": false
  },
  "sort": {
    "supported": false
  },
  "changePassword": {
    "supported": true
  },
  "authenticationSchemes": [
    {
      "name": "Keytone Authentication",
      "documentationUrl": "http://keystone.openstack.org/",
      "primary": true,
      "specUrl": "http://specs.openstack.org/openstack/keystone-specs",
      "type": "keystonetoken",
      "description": "Authentication using Keystone"
    }
  ],
  "documentationUrl": null,
  "xmlDataFormat": {
    "supported": false
  },
  "patch": {
    "supported": true
  }
}

Known limitations and future work

  • It's unclear if SCIM standard specifies or not the format of Error messages. This extension reuses Keystone error messages.

fiware-keystone-scim's People

Contributors

alvarovega avatar dmoranj avatar espencer avatar fgalan avatar jason-fox avatar jcanonav avatar magarciasopo avatar mapedraza avatar rodvic avatar xavierval avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fiware-keystone-scim's Issues

bug in pagination

users are paginated in a wrong way.

If I create 18 users like:
user1... user18 and then I try to list then I see:

keystone scim API: "GET /v3/OS-SCIM/Users?domain_id=2d11ea01a00c423b919cb336adb99c76&startIndex=0&count=15"

Keystone scim API: GET /v3/OS-SCIM/Users?domain_id=2d11ea01a00c423b919cb336adb99c76&startIndex=15&count=15

So its seems a keystone-scim bug/issue https://github.com/telefonicaid/fiware-keystone-scim

errors should respect Accept header

When I issue this command, requesting a resource id with spaces in it, curl http://localhost:35357/v3/OS-SCIM/Users/"name with spaces" -H "X-Auth-Token: valid_token" -H "Content-Type: application/json" -H "Accept: application/json", I get the following HTML content describing the error, instead of the typical Json format:

<head>
<title>Error response</title>
</head>
<body>
<h1>Error response</h1>
<p>Error code 400.
<p>Message: Bad request syntax ('GET /v3/OS-SCIM/Users/name with spaces HTTP/1.1').
<p>Error code explanation: 400 = Bad request syntax or unsupported method.
</body>

Provide full SCIM pagination results

According with SCIM spec: http://www.simplecloud.info/specs/draft-scim-api-01.html section 3.2.2.3 pagination results should provide totalResults, ItemsPerPage, startindex

itemsPerPage    Non-negative Integer. Specifies the number of search results returned in a query response page; e.g., 10.
totalResults    Non-negative Integer. Specifies the total number of results matching the Consumer query; e.g., 1000.
startIndex  The 1-based index of the first result in the current set of search results; e.g., 1. 

Pagination do not works listing users without provide domain_id

Works OK:

curl -s -X GET -H "x-auth-token: $SMARTVALENCIA_ADMIN_TOKEN" \
  "http://${KEYSTONE_HOST}/v3/OS-SCIM/Users?domain_id=${ID_DOM1}&startIndex=1&count=1"

Do not works (do not returns just 1)

curl -s -X GET -H "x-auth-token: $CLOUD_ADMIN_TOKEN" \
  "http://${KEYSTONE_HOST}/v3/OS-SCIM/Users?startIndex=1&count=1"

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.