[[ux_pdp]]

Authorization back-end (PDP) guide
----------------------------------

The authorization process in UNICORE/X requires that nearly all operations 
must be authorized prior to execution (exceptions may be safely ignored).
 
UNICORE allows to choose which authorization back-end is used. The module which
is responsible for this operation is called Policy Decision Point (PDP). 
You can choose one among already available PDP modules or even develop your own engine.

Local PDPs use a set of policy files to reach an authorisation decision, remote PDPs query
a remote service.

Local UNICORE PDPs use the XACML language to express the authorization policy. The XACML policy
language is introduced in the xref:ux_policies[Guide to XACML security policies].
You can also review this guide if you want to have a deeper understanding of the authorization 
process. 

 
Basic configuration  
~~~~~~~~~~~~~~~~~~~

There are three options in the 'uas.config' file which are relevant to all PDPs:
  
 - +uas.security.accesscontrol+ (values: +true+ or +false+) This boolean property can be used 
to completely turn off the authorization. This guide makes sense only if this option is set to +true+.
Except for test scenarios this should never be switched off, otherwise every user can in principle 
access all resources on the server.

 - +uas.security.accesscontrol.pdp+ (value: full class name) This property is used to choose
which PDP module is being used.

 - +uas.security.accesscontrol.pdp.config+ (value: file path) This property provides a location
of a configuration file of the selected PDP.  

Available PDP modules
~~~~~~~~~~~~~~~~~~~~~

==== XACML 2.0 PDP

The implementation class of this module is: +eu.unicore.uas.pdp.local.LocalHerasafPDP+ so
to enable this module use the following configuration in uas.config:

--------
uas.security.accesscontrol.pdp.config=<CONFIG_DIR>/xacml2.conf
uas.security.accesscontrol.pdp=eu.unicore.uas.pdp.local.LocalHerasafPDP
--------

The configuration file content is very simplistic as it is enough to define only few options: 

--------
# The directory where XACML 2.0 policy files are stored 
localpdp.directory=conf/xacml2Policies

# Wildcard expression to select actual policy files from the directory defined above  
localpdp.filesWildcard=*.xml

# Combining algorithm for the policies. You can use the full XACML id or its last part. 
localpdp.combiningAlg=first-applicable
----------

The policies from the +localpdp.directory+ are always evaluated in alphabetical order,
so it is good to name files with a number. By default the first-applicable combining algorithm is
used and UNICORE policy is stored in two files: '01coreServices.xml' and '99finalDeny.xml'.
The first file contains the default access policy, the latter a single fall through deny rule.
Therefore you can put your own policies using an additional file in file named 
e.g. '50localRules.xml'.

The policies are reloaded whenever you change (or touch) the configuration file of this PDP, e.g.
like this:

--------
touch conf/xacml2.conf
--------


==== XACML 1.x PDP

The implementation class of this module is: +eu.unicore.uas.pdp.localsun.LocalSunPDP+ so
to enable this module use the following configuration in uas.config:

--------
uas.security.accesscontrol.pdp.config=conf/xacml.config
uas.security.accesscontrol.pdp=eu.unicore.uas.pdp.localsun.LocalSunPDP
--------

This module is the one that was the only available option in UNICORE
prior to release 6.4.0 

The rules are contained in one or more policy files as listed in the 
'xacml.config' configuration file. However note that in case of 
this legacy implementation it mostly doesn't make sense to use more then 
one file as it not possible to control the combining algorithm (which would be 
only-one-applicable). Therefore the configuration file is rather absolutely constant:

-------
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://sunxacml.sourceforge.net/schema/config-0.3"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        defaultPDP="pdp" defaultAttributeFactory="attr"
        defaultCombiningAlgFactory="comb" defaultFunctionFactory="func">
  <pdp name="pdp">
    <attributeFinderModule class="com.sun.xacml.finder.impl.CurrentEnvModule"/>
    <attributeFinderModule class="com.sun.xacml.finder.impl.SelectorModule"/>
    <policyFinderModule class="com.sun.xacml.finder.impl.FilePolicyModule">
      <list>
        <string>conf/security_policy.xml</string>
      </list>
    </policyFinderModule>
  </pdp>
  <attributeFactory name="attr" useStandardDatatypes="true"/>
  <combiningAlgFactory name="comb" useStandardAlgorithms="true"/>
  <functionFactory name="func" useStandardFunctions="true">
 
  </functionFactory>
</config>
-------

In case you modified the policy file(s), you can force a reload into the running server
by "touch"ing the xacml.conf configuration file. For example, under Unix you can execute

--------
touch conf/xacml.conf
--------

Opening the file in an editor and saving it will also do the trick.


==== Remote SAML/XACML 2.0 PDP (Argus PDP)

This PDP allows for outsourcing authorization decision to the remote PDP service. 
Typically the https://twiki.cern.ch/twiki/bin/view/EGEE/AuthorizationFramework[Argus PDP] 
is used for this purpose but in principle any PDP which implements the 
SAML XAML Authorization Query Protocol can be used. 

The implementation class of this module is: +eu.unicore.uas.pdp.argus.ArgusPDP+ so
to enable this module use the following configuration in uas.config:

-------
uas.security.accesscontrol.pdp.config=<CONFIG_DIR>/argus.config
uas.security.accesscontrol.pdp=eu.unicore.uas.pdp.argus.ArgusPDP
--------

The PDP configuration is very simple as it is only required to provide the Argus endpoint 
and query timeout (in milliseconds). 

--------
arguspdp.serverAddress=https://argus.exampledomain.org:8152/authz
arguspdp.queryTimeout=15000
--------

You can use both http and https addresses. In the latter case server's certificate is used 
to make the connection. 

If the remote PDP can not be contacted due to any reason the authorization decision is always deny.


