Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6544969
Migrate module to use saml11 + ws-security libraries
tvdijen Mar 24, 2024
dea9ca9
allow hosted metadata again. This lets me see it in the admin ui (#18)
monkeyiq Apr 29, 2024
0664cf8
Fix constant
tvdijen Aug 31, 2024
c46448d
Back to SSP release-branch
tvdijen Aug 31, 2024
12c7a97
Fix constants
tvdijen Aug 31, 2024
5ebd2ee
Fixes
tvdijen Sep 1, 2024
28a7aa2
Feature/standalone metadata (#21)
tvdijen Sep 1, 2024
b761d26
Update ws-security lib
tvdijen Oct 2, 2024
ac846f3
WIP: Add mex-endpoint
tvdijen Sep 3, 2024
c47ece5
Use updated ws-security lib
tvdijen Sep 10, 2024
bb9cfc3
Refactor
tvdijen Sep 23, 2024
70dbde6
Refactor
tvdijen Sep 23, 2024
073db4c
Fix IncludeToken
tvdijen Sep 23, 2024
ffd0299
Add certificate policies
tvdijen Sep 23, 2024
67c4fed
Add IssuedToken policies
tvdijen Sep 23, 2024
409a946
Refactor
tvdijen Sep 23, 2024
0fb4515
Add IssuedToken policies
tvdijen Sep 23, 2024
a81c07d
Add WS-trust 1.3 policies
tvdijen Sep 23, 2024
00bb6bc
Fix namespaces
tvdijen Oct 2, 2024
1e2d4ab
Add IssuedToken policies
tvdijen Oct 3, 2024
adae2db
Add wsdl:types and wsdl:message elements
tvdijen Oct 3, 2024
11e6f1e
Add wsdl:portTtype elements
tvdijen Oct 3, 2024
8e00931
Add bindings
tvdijen Oct 8, 2024
76672ea
Import interoperability-test from ws-security lib
tvdijen Oct 8, 2024
7a757d8
Fix coding style
tvdijen Oct 8, 2024
9236250
Add last binding and service
tvdijen Oct 8, 2024
e4dbf55
Add missing namespaces
tvdijen Oct 14, 2024
51cb9bc
Add yet another namespace decl
tvdijen Oct 16, 2024
0a0ed14
Fix constant
tvdijen Oct 16, 2024
6db319b
Fix constant
tvdijen Oct 16, 2024
c7ccc08
Fix typo
tvdijen Oct 16, 2024
da3aedf
Use correct version of ws-addressing
tvdijen Oct 16, 2024
660c9c0
Disable anything WS-trust 1.3 related - May remove later
tvdijen Oct 17, 2024
7ff5c0a
Add usernamemixed endpoint
tvdijen Oct 17, 2024
fd1c8e2
Fix
tvdijen Oct 22, 2024
8bcad6f
Fix rebase: remove duplicate use-statements
tvdijen Oct 23, 2024
7a8d3d0
Fix namespace
tvdijen Oct 23, 2024
23ef3ab
Fix missing parameter
tvdijen Oct 23, 2024
6e41286
Fix return type
tvdijen Oct 23, 2024
48340e7
Fix parameter type
tvdijen Oct 23, 2024
116056e
Fix constant
tvdijen Oct 23, 2024
2634e05
Fix namespace for callback
tvdijen Oct 23, 2024
40581d9
Fix namespace
tvdijen Oct 23, 2024
9634e9a
Fix missing use-statement
tvdijen Oct 23, 2024
f1d23f1
Passive response
tvdijen Nov 14, 2024
4a1287c
Bump dependencies
tvdijen Jan 9, 2025
c7662d3
Bump dependencies
tvdijen Jan 10, 2025
a19d91e
Re-add code that got lost earlier
tvdijen Jan 15, 2025
9af5562
Consider wauth-parameter when processing request
tvdijen Jan 16, 2025
5916072
Log the active response under debug-logging
tvdijen Jan 16, 2025
080befd
Add debug logging
tvdijen Feb 17, 2025
029cafb
Merge branch 'master' into feature/metadata-exchange
tvdijen Feb 17, 2025
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
80 changes: 80 additions & 0 deletions .github/workflows/interoperability.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---

name: Interoperability

on: # yamllint disable-line rule:truthy
push:
branches: ['**']
paths-ignore:
- '**.md'
- '**.yml'
pull_request:
branches: [master, release-*]
paths-ignore:
- '**.md'
- '**.yml'
workflow_dispatch:

jobs:
edugain:
name: "Interoperability tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.2']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, hash, mbstring, openssl, pcre, spl, xml
tools: composer:v2
ini-values: error_reporting=E_ALL, memory_limit=-1
coverage: none

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v4

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: $(composer config cache-files-dir)
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Get current date
id: date
run: |
echo "{date}={$(date +'%Y-%m-%d')}" >> "$GITHUB_STATE"

- name: Cache metadata
id: cache-metadata
uses: actions/cache@v4
with:
path: /tmp/metadata
key: ${{ runner.os }}-metadata-${{ env.date }}
restore-keys: ${{ runner.os }}-metadata-

- name: Run unit tests
run: |
./vendor/bin/phpunit -c phpunit-interoperability.xml
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"autoload-dev": {
"psr-4": {
"SimpleSAML\\Test\\Module\\adfs\\": "vendor/simplesamlphp/simplesamlphp/tests",
"SimpleSAML\\Test\\Utils\\": "vendor/simplesamlphp/simplesamlphp/tests/Utils"
}
},
Expand All @@ -39,18 +40,19 @@

"beste/clock": "^3.0",
"psr/clock": "^1.0",
"simplesamlphp/assert": "^1.1",
"simplesamlphp/saml11": "^1.0",
"simplesamlphp/assert": "~1.8.0",
"simplesamlphp/saml11": "~1.2.0",
"simplesamlphp/saml2": "^5@dev",
"simplesamlphp/simplesamlphp": "^2.4",
"simplesamlphp/ws-security": "^1.6",
"simplesamlphp/xml-common": "^1.16",
"simplesamlphp/xml-security": "^1.9",
"simplesamlphp/xml-common": "~1.24.0",
"simplesamlphp/xml-security": "~1.13.0",
"simplesamlphp/xml-soap": "~1.7.0",
"simplesamlphp/xml-wsdl": "~1.2.0",
"simplesamlphp/ws-security": "~1.9.0",
"symfony/http-foundation": "^6.4"
},
"require-dev": {
"simplesamlphp/simplesamlphp-test-framework": "^1.6",
"simplesamlphp/xml-security": "^1.7"
"simplesamlphp/simplesamlphp-test-framework": "~1.8.0"
},
"support": {
"issues": "https://github.com/simplesamlphp/simplesamlphp-module-adfs/issues",
Expand Down
8 changes: 8 additions & 0 deletions phpunit-interoperability.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Test Suite - Interoperability">
<directory>./tests/InterOperability</directory>
</testsuite>
</testsuites>
</phpunit>
14 changes: 14 additions & 0 deletions routing/routes/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ adfs-prp-legacy:
_controller: 'SimpleSAML\Module\adfs\Controller\Adfs::prp'
}
methods: [GET, POST]

adfs-wstrust-mex:
path: /ws-trust/mex
defaults: {
_controller: 'SimpleSAML\Module\adfs\Controller\Adfs::mex'
}
methods: [GET]

adfs-wstrust-usernamemixed:
path: /ws-trust/2005/services/usernamemixed
defaults: {
_controller: 'SimpleSAML\Module\adfs\Controller\Adfs::usernamemixed'
}
methods: [POST]
97 changes: 96 additions & 1 deletion src/Controller/Adfs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
use SimpleSAML\Error as SspError;
use SimpleSAML\Module\adfs\IdP\ADFS as ADFS_IDP;
use SimpleSAML\Module\adfs\IdP\MetadataBuilder;
use SimpleSAML\Module\adfs\IdP\PassiveIdP;
use SimpleSAML\Module\adfs\MetadataExchange;
use SimpleSAML\SOAP\XML\env_200305\Envelope;
use SimpleSAML\XML\DOMDocumentFactory;
use Symfony\Component\HttpFoundation\{Request, Response, StreamedResponse};

/**
Expand Down Expand Up @@ -77,7 +81,6 @@ public function metadata(Request $request): Response
// Some products like DirX are known to break on pretty-printed XML
$document->ownerDocument->formatOutput = false;
$document->ownerDocument->encoding = 'UTF-8';

$metaxml = $document->ownerDocument->saveXML();

$response = new Response();
Expand Down Expand Up @@ -137,4 +140,96 @@ function () use ($idp, /** @scrutinizer ignore-type */ $assocId, $relayState, $l
}
throw new SspError\BadRequest("Missing parameter 'wa' or 'assocId' in request.");
}


/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function mex(Request $request): Response
{
if (!$this->config->getOptionalBoolean('enable.adfs-idp', false)) {
throw new SspError\Error('NOACCESS');
}

// check if valid local session exists
$authUtils = new Utils\Auth();
if ($this->config->getOptionalBoolean('admin.protectmetadata', false) && !$authUtils->isAdmin()) {
return new StreamedResponse([$authUtils, 'requireAdmin']);
}

$mexBuilder = new MetadataExchange();
$document = $mexBuilder->buildDocument()->toXML();
// Some products like DirX are known to break on pretty-printed XML
$document->ownerDocument->formatOutput = false;
$document->ownerDocument->encoding = 'UTF-8';

$document->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:tns',
'http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice',
);

$document->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:soapenc',
'http://schemas.xmlsoap.org/soap/encoding/',
);

$document->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:msc',
'http://schemas.microsoft.com/ws/2005/12/wsdl/contract',
);

$document->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:wsam',
'http://www.w3.org/2007/05/addressing/metadata',
);

$document->setAttributeNS(
'http://www.w3.org/2000/xmlns/',
'xmlns:wsap',
'http://schemas.xmlsoap.org/ws/2004/08/addressing/policy',
);

$metaxml = $document->ownerDocument->saveXML();

$response = new Response();
$response->setEtag(hash('sha256', $metaxml));
$response->setPublic();
if ($response->isNotModified($request)) {
return $response;
}
$response->headers->set('Content-Type', 'text/xml');
$response->setContent($metaxml);

return $response;
}


/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function usernamemixed(Request $request): Response
{
if (!$this->config->getOptionalBoolean('enable.adfs-idp', false)) {
throw new SspError\Error('NOACCESS');
}

$soapMessage = $request->getContent();
if ($soapMessage === false) {
throw new SspError\BadRequest('Missing SOAP-content.');
}

$domDocument = DOMDocumentFactory::fromString($soapMessage);
$soapEnvelope = Envelope::fromXML($domDocument->documentElement);

$idpEntityId = $this->metadata->getMetaDataCurrentEntityID('adfs-idp-hosted');
$idp = PassiveIdP::getById($this->config, 'adfs:' . $idpEntityId);

return ADFS_IDP::receivePassiveAuthnRequest($request, $soapEnvelope, $idp);
}
}
Loading
Loading