Skip to content

Commit

Permalink
Azuread privatekeyjwt (#161)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README_FINE_GRAIN_PERMISSION.md

* Update README_FINE_GRAIN_PERMISSION.md

* https://jsw.ibm.com/browse/DBACLD-97311

* Update README.md

* SiaSin review

* SiaSin review

* Update README.md

* https://jsw.ibm.com/browse/DBACLD-110090

* Update README.md

* first private_key_jwt doc

* Update README_WITH_PRIVATE_KEY_JWT.md

* Rule Designer Update

* new images

* Azure AD rename in Microsoft Entra ID

* Update README.md

* Update README.md

* Update README.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* Update README_WITH_CLIENT_SECRET.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* Update README_WITH_CLIENT_SECRET.md

* First Review (#159)

* First Review

* Finalize change in the menu

* Update README.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* Update README_WITH_PRIVATE_KEY_JWT.md

* new script

---------

Co-authored-by: Mathias Mouly <[email protected]>
  • Loading branch information
lgrateau and mmouly authored Oct 20, 2023
1 parent d38c78b commit d5484f7
Show file tree
Hide file tree
Showing 11 changed files with 1,217 additions and 497 deletions.
544 changes: 47 additions & 497 deletions authentication/AzureAD/README.md

Large diffs are not rendered by default.

506 changes: 506 additions & 0 deletions authentication/AzureAD/README_WITH_CLIENT_SECRET.md

Large diffs are not rendered by default.

468 changes: 468 additions & 0 deletions authentication/AzureAD/README_WITH_PRIVATE_KEY_JWT.md

Large diffs are not rendered by default.

Binary file modified authentication/AzureAD/azuread-odm-script.zip
Binary file not shown.
78 changes: 78 additions & 0 deletions authentication/AzureAD/generateTemplateForPrivateKeyJWT.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
export AZUREAD_CLAIM_GROUPS="groups"
export AZUREAD_CLAIM_LOGIN="loginName"
OUTPUT_DIR=./outputPKeyJWT
TEMPLATE_DIR=./templates_for_privatekeyjwt

function usage {
cat <<EOF
Usage: $(basename "$0") [-<option letter> <option value>] [-h]
Options:
-g : AZUREAD ODM Group ID
-i : Client ID
-n : AZUREAD domain (AZUREAD server name)
-a : Allow others domains (Optional)
Usage example: $0 -i AzureADClientId -n <Application ID (GUID)> -g <GROUP ID (GUID)> [-a <domain name>]"
EOF
}

while getopts "x:i:n:s:g:ha:" option; do
case "${option}" in
g) AZUREAD_ODM_GROUP_ID=${OPTARG};;
i) AZUREAD_CLIENT_ID=${OPTARG};;
n) AZUREAD_SERVER_NAME=${OPTARG};;
a) ALLOW_DOMAIN=${OPTARG};;
h) usage; exit 0;;
*) usage; exit 1;;
esac
done

if [[ -z ${AZUREAD_ODM_GROUP_ID} ]]; then
echo "AZUREAD_ODM_GROUP_ID has to be provided, either as in environment or with -g."
exit 1
fi
if [[ -z ${AZUREAD_CLIENT_ID} ]]; then
echo "AZUREAD_CLIENT_ID has to be provided, either as in environment or with -i."
exit 1
fi
if [[ -z ${AZUREAD_SERVER_NAME} ]]; then
echo "AZUREAD_SERVER_NAME has to be provided, either as in environment or with -n."
exit 1
fi

if [[ ${AZUREAD_SERVER_NAME} != "https://.*" ]]; then
AZUREAD_SERVER_URL=https://login.microsoftonline.com/${AZUREAD_SERVER_NAME}
else
AZUREAD_SERVER_URL=${AZUREAD_SERVER_NAME}
fi

mkdir -p $OUTPUT_DIR && cp $TEMPLATE_DIR/* $OUTPUT_DIR
echo "Generating files for AZUREAD"
sed -i.bak 's|AZUREAD_CLIENT_ID|'$AZUREAD_CLIENT_ID'|g' $OUTPUT_DIR/*
sed -i.bak 's|AZUREAD_ODM_GROUP_ID|'$AZUREAD_ODM_GROUP_ID'|g' $OUTPUT_DIR/*
sed -i.bak 's|AZUREAD_SERVER_URL|'$AZUREAD_SERVER_URL'|g' $OUTPUT_DIR/*
# Claim replacement
sed -i.bak 's|AZUREAD_CLAIM_GROUPS|'$AZUREAD_CLAIM_GROUPS'|g' $OUTPUT_DIR/*
sed -i.bak 's|AZUREAD_CLAIM_LOGIN|'$AZUREAD_CLAIM_LOGIN'|g' $OUTPUT_DIR/*
if [ ! -z "$ALLOW_DOMAIN" ]; then
sed -i.bak 's|login.microsoftonline.com|'login.microsoftonline.com,$ALLOW_DOMAIN'|g' $OUTPUT_DIR/*
fi
rm -f $OUTPUT_DIR/*.bak
Binary file added authentication/AzureAD/images/AddRDCallback.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified authentication/AzureAD/images/AddURI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"providers": [
{
"name": "azure_ad",
"grantType": "client_credentials",
"clientAssertionAliasName": "myodmcompany",
"authorizationURL": "AZUREAD_SERVER_URL/oauth2/v2.0/authorize",
"tokenURL": "AZUREAD_SERVER_URL/oauth2/v2.0/token",
"scope": "AZUREAD_CLIENT_ID/.default",
"clientId": "AZUREAD_CLIENT_ID",
"logoutURL": "AZUREAD_SERVER_URL/oauth2/v2.0/logout"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
OPENID_SERVER_URL=AZUREAD_SERVER_URL
OPENID_PROVIDER=azure_ad
OPENID_AUTHORIZATION_URL=AZUREAD_SERVER_URL/oauth2/v2.0/authorize
OPENID_TOKEN_URL=AZUREAD_SERVER_URL/oauth2/v2.0/token
OPENID_CLIENT_ID=AZUREAD_CLIENT_ID
OPENID_CLIENT_ASSERTION_ALIAS_NAME=myodmcompany
OPENID_LOGOUT_URL=AZUREAD_SERVER_URL/oauth2/v2.0/logout
OPENID_ALLOWED_DOMAINS=login.microsoftonline.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

<server>

<variable name="ServerHost" value="AZUREAD_SERVER_URL"/>

<!-- Open ID Connect -->
<!-- Client with inbound propagation set to supported -->
<openidConnectClient authFilterRef="browserAuthFilter" id="odm" scope="openid" accessTokenInLtpaCookie="true"
clientId="AZUREAD_CLIENT_ID" tokenEndpointAuthMethod="private_key_jwt" keyAliasName="myodmcompany" sslRef="odmDefaultSSLConfig"
signatureAlgorithm="RS256" inboundPropagation="supported"
jwkEndpointUrl="${ServerHost}/discovery/v2.0/keys"
issuerIdentifier="${ServerHost}/v2.0"
authorizationEndpointUrl="${ServerHost}/oauth2/v2.0/authorize"
tokenEndpointUrl="${ServerHost}/oauth2/v2.0/token"
userIdentifier="email" groupIdentifier="groups" audiences="ALL_AUDIENCES"/>

<!-- Client with inbound propagation set to required -->
<openidConnectClient authFilterRef="apiAuthFilter" id="odmapi" scope="openid"
clientId="AZUREAD_CLIENT_ID"
signatureAlgorithm="RS256" inboundPropagation="required"
jwkEndpointUrl="${ServerHost}/discovery/v2.0/keys"
issuerIdentifier="${ServerHost}/v2.0"
authorizationEndpointUrl="${ServerHost}/oauth2/v2.0/authorize"
tokenEndpointUrl="${ServerHost}/oauth2/v2.0/token"
userIdentifier="identity" groupIdentifier="groups" audiences="ALL_AUDIENCES"/>
</server>
70 changes: 70 additions & 0 deletions authentication/AzureAD/templates_for_privatekeyjwt/webSecurity.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<server>
<!-- basic registry to manage rest-api / ruledesigner and DC to RES deployment -->
<basicRegistry id="basic" realm="basic">
<user name="odmAdmin" password="odmAdmin"/>
<group name="basicAdministrators">
<member name="odmAdmin" />
</group>
</basicRegistry>
<variable name="odm.resAdministrators.group2" value="group:basic/basicAdministrators"/>
<variable name="odm.resExecutors.group2" value="group:basic/basicAdministrators"/>
<variable name="odm.rtsAdministrators.group2" value="group:basic/basicAdministrators"/>

<!-- group mapping to authorize users of the OKTA_ODM_GROUP group -->
<variable name="group1" value="group:AZUREAD_SERVER_URL/v2.0/AZUREAD_ODM_GROUP_ID"/>

<variable name="odm.rtsAdministrators.group1" value="${group1}"/>
<variable name="odm.rtsInstallers.group1" value="${group1}"/>
<variable name="odm.rtsConfigManagers.group1" value="${group1}"/>
<variable name="odm.resAdministrators.group1" value="${group1}"/>
<variable name="odm.resDeployers.group1" value="${group1}"/>
<variable name="odm.resMonitors.group1" value="${group1}"/>
<variable name="odm.resExecutors.group1" value="${group1}"/>

<!-- OPTIONAL: The following section concerning mapping and authfilter override is only necessary for the Client Credentials flow
that is used for :
- DC to RES deployment (requestUrl id="res3")
- Runtime execution Rest-Api call (requestUrl id="ds1"). When set, DecisionService UI is only accessible using Basic authentication.
If basic authentication is used instead, then the following section can be removed -->

<!-- user mapping to authorize CLIENT_CREDENTIALS using CLIENT_ID -->
<variable name="user1" value="user:AZUREAD_SERVER_URL/v2.0/AZUREAD_CLIENT_ID"/>

<variable name="odm.rtsAdministrators.user1" value="${user1}"/>
<variable name="odm.resAdministrators.user1" value="${user1}"/>
<variable name="odm.resExecutors.user1" value="${user1}"/>

<authFilter id="browserAuthFilter">
<requestHeader id="allowBasicAuth" matchType="notContain" name="Authorization" value="Basic" />
<requestUrl id="ds1" matchType="notContain" urlPattern="DecisionService/rest"/>
<!-- RES console -->
<requestUrl id="res1" matchType="notContain" urlPattern="/res/auth"/>
<requestUrl id="res2" matchType="notContain" urlPattern="/res/repositoryService"/>
<requestUrl id="res3" matchType="notContain" urlPattern="/res/api"/>
<!-- Enterprise console -->
<requestUrl id="ec1" matchType="notContain" urlPattern="/teamserver/rts-sync"/>
<requestUrl id="ec2" matchType="notContain" urlPattern="/teamserver/remoting"/>
<requestUrl id="ec3" matchType="notContain" urlPattern="/teamserver/servlet/SessionServlet"/>
<!-- Business console -->
<requestUrl id="bc1" matchType="notContain" urlPattern="/decisioncenter/rts-sync"/>
<requestUrl id="bc2" matchType="notContain" urlPattern="/decisioncenter/remoting"/>
<requestUrl id="bc3" matchType="notContain" urlPattern="/decisioncenter/servlet/SessionServlet"/>
<!-- Decision Center API -->
<requestUrl id="dcapi" matchType="notContain" urlPattern="/decisioncenter-api/v1/" />
<!-- Decision Runner -->
<requestUrl id="dr1" matchType="notContain" urlPattern="/DecisionRunner/api"/>
<requestUrl id="dr2" matchType="notContain" urlPattern="/DecisionRunner/apiauth"/>
<requestUrl id="dr3" matchType="notContain" urlPattern="/DecisionRunner/serverinfo"/>
<!-- SSP (DVS) -->
<requestUrl id="tg1" matchType="notContain" urlPattern="/testing/sspService"/>
<requestUrl id="tg2" matchType="notContain" urlPattern="/testing/serverinfo"/>
</authFilter>

<!-- Note: The apiAuthFilter should be complementary to the browserAuthFilter -->
<authFilter id="apiAuthFilter">
<!-- This line is to support OIDC and BA by detecting the header -->
<requestHeader id="allowBasicAuth" matchType="contains" name="Authorization" value="Bearer" />
<requestUrl id="apiurl" matchType="contains" urlPattern="/DecisionService/rest|/res/api|/res/auth|/res/repositoryService|/teamserver/rts-sync|/teamserver/remoting|/teamserver/servlet/SessionServlet|/decisioncenter/rts-sync|/decisioncenter/remoting|/decisioncenter/servlet/SessionServlet|/decisioncenter-api/v1|/DecisionRunner/api|/DecisionRunner/apiauth|/DecisionRunner/serverinfo|/testing/sspService|/testing/serverinfo"/>
</authFilter>

</server>

0 comments on commit d5484f7

Please sign in to comment.