Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 150 additions & 40 deletions doc/appendix/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,44 @@ Working with defaults

Default mapping:

XML Example:

.. code-block:: XML

<?xml version="1.0" encoding="UTF-8" ?>
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docs.rackspace.com/identity/api/ext/MappingRules"
version="RAX-1">
<rules>
<rule>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for tag in all these XML examples? This is not in YAML

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I wonder if @nikhil09541 , or Tim Cline may have more context as to why it is needed as this tag seems to be an identity requirement and is used in the test cases repo.

@nicko-winner nicko-winner Aug 4, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<local>
<user>
<domain value="{D}"/>
<name value="{D}"/>
<email value="{D}"/>
<roles value="{D}"/>
<expire value="{D}"/>
</user>
</local>
</rule>
</rules>
</mapping>

YAML Example:

.. code-block:: yaml

1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D}"
9 roles: "{D}"
10 expire: "{D}"
1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D}"
9 roles: "{D}"
10 expire: "{D}"


Resulting attributes:
Expand All @@ -95,18 +121,45 @@ Resulting attributes:
Accessing default from a different field:
-----------------------------------------

XML Example:

.. code-block:: XML

<?xml version="1.0" encoding="UTF-8" ?>
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docs.rackspace.com/identity/api/ext/MappingRules"
version="RAX-1">
<rules>
<rule>
<local>
<user>
<domain value="{D}"/>
<name value="{D}"/>
<email value="{D(name)}@rackspace.com"/>
<roles value="{D}"/>
<expire value="{D}"/>
</user>
</local>
</rule>
</rules>
</mapping>

YAML Example:

.. code-block:: yaml

1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D(name)}@rackspace.com"
9 roles: "{D}"
10 expire: "{D}"
1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D(name)}@rackspace.com"
9 roles: "{D}"
10 expire: "{D}"


Resulting attributes:

Expand All @@ -125,18 +178,47 @@ Resulting attributes:
More complex example with multiple substitutions
------------------------------------------------

XML Example:

.. code-block:: XML

<?xml version="1.0" encoding="UTF-8" ?>
<root>
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docs.rackspace.com/identity/api/ext/MappingRules"
version="RAX-1">
<rules>
<rule>
<local>
<user>
<domain value="{D}"/>
<name value="{D}"/>
<email value="{D(name)} &lt;{D(name)}@{D(domain)}.rackspace.com&gt;"/>
<roles value="{D}"/>
<expire value="{D}"/>
</user>
</local>
</rule>
</rules>
</mapping>
</root>

YAML Example:

.. code-block:: yaml

1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D(name)} <{D(name)}@{D(domain)}.rackspace.com>"
9 roles: "{D}"
10 expire: "{D}"
1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{D(name)} <{D(name)}@{D(domain)}.rackspace.com>"
9 roles: "{D}"
10 expire: "{D}"


Resulting Attributes:

Expand All @@ -155,18 +237,46 @@ Resulting Attributes:
Mixing in non-default attributes
--------------------------------

XML Example:

.. code-block:: XML

<?xml version="1.0" encoding="UTF-8" ?>
<root>
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docs.rackspace.com/identity/api/ext/MappingRules"
version="RAX-1">
<rules>
<rule>
<local>
<user>
<domain value="{D}"/>
<name value="{D}"/>
<email value="{At(FirstName)} {At(LastName)} &lt;{D(name)}@{D(domain)}.rackspace.com&gt;"/>
<roles value="{D}"/>
<expire value="{D}"/>
</user>
</local>
</rule>
</rules>
</mapping>
</root>

YAML Example:

.. code-block:: yaml

1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{At(FirstName)} {At(LastName)} <{D(name)}@{D(domain)}.rackspace.com>"
9 roles: "{D}"
10 expire: "{D}"
1 mapping:
2 version: RAX-1
3 rules:
4 - local:
5 user:
6 domain: "{D}"
7 name: "{D}"
8 email: "{At(FirstName)} {At(LastName)} <{D(name)}@{D(domain)}.rackspace.com>"
9 roles: "{D}"
10 expire: "{D}"


Resulting Attributes:
Expand Down
71 changes: 68 additions & 3 deletions doc/appendix/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ a basic understanding of the following technologies:
to be human friendly. YAML is very similar to JSON but allows for useful
features such as comments and the ability to easily input multi-line data.
Attribute mapping policies are written in YAML.

- **XML 1.0**: Extensible Markup Language (XML) is a universal format,
maintained by the W3C, used for representation and transfer of structured
data on the web or between different applications. XML is a markup language
that defines set of rules for encoding documents in a format that is both
human-readable and machine-readable.

What is Attribute Mapping?
==========================
Expand Down Expand Up @@ -135,6 +141,67 @@ The following attribute mapping policy implements the rules described
in the previous section. The rest of this document provides a guide
for writing such polices.

XML Example:

.. code-block:: XML

<?xml version="1.0" encoding="UTF-8" ?>
<mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://docs.rackspace.com/identity/api/ext/MappingRules"
version="RAX-1">
<description>The following is an attribute mapping for Widgets.com.</description>
<rules>
<rule>
<local>
<user>
<domain value="{D}"/>
<name value="{D}"/>
<email value="{At(email)}"/>
<roles value="{0}"/>
<expire value="{D}"/>
</user>
</local>
</rule>
</rules>
<remote>
<attribute multiValue="true" />
<path>
(:
The following describes the rules for assigning roles to
users.
:)
for $group in mapping:get-attributes('groups') return
(:
If a user is a manager they get ticketing:admin,
If they are not a contractor then they also get billing:observer
Managers become admin based on the project that they are working on
:)
if ($group = 'managers') then
(
'ticketing:admin',
if (not(mapping:get-attributes('groups')='contractors')) then 'billing:observer' else
(),
for $project in mapping:get-attributes('manager_projects') return
(
if ($project = 'widgets_ui') then 'admin/777654' else
if ($project = 'widgets_mobile') then 'admin/887655' else
if ($project = 'widgets_platform') then 'admin/779956' else
()
)
) else
(:
If a user is a member of the linux_user group they get the
nova:observer role.
:)
if ($group = 'linux_user') then 'nova:observer' else
()
</path>
</remote>
</mapping>

YAML Example:

.. code-block:: yaml

1 mapping:
Expand Down Expand Up @@ -181,6 +248,4 @@ for writing such polices.
42 nova:observer role.
43 :)
44 if ($group = 'linux_user') then 'nova:observer' else
45 ()


45 ()
Loading