Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSP-2030_OIDC_module_switch_to_ProcessingChain_for_authproc_support_consent_mod #228

Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7455667
Switch to processing chain for authproc filters
ioigoume Jun 11, 2024
d6f0aff
Remove obsolete code
ioigoume Jun 11, 2024
089be26
remove obsolete code
ioigoume Jun 12, 2024
e94ef0b
ReturnURL to use the new authorization endpoint
ioigoume Jun 12, 2024
ae6a7bf
Refactored AuthorizationControllerTest.php and AuthenticationServiceT…
ioigoume Jun 12, 2024
d4860a5
Fix psalm. Fix unit tests.
ioigoume Jun 17, 2024
409c6f5
Decouple authentication from getAuthenticateUser and handleState
ioigoume Jun 21, 2024
b2095a9
AuthenticationServiceTest::testItAuthenticates improve
ioigoume Jun 21, 2024
ca5942f
Remove unused parameters
ioigoume Jun 21, 2024
ec9c1db
rename hanldeState to processRequest
ioigoume Jun 21, 2024
92172b6
Merge branch 'wip-version-6' into SSP-2030_OIDC_module_switch_to_Proc…
cicnavi Jun 23, 2024
ad6d2b3
Fix db migration other warnings (#230)
pradtke Jun 21, 2024
b5811a2
Update docker run to use newer ssp image
pradtke Jun 21, 2024
7a55b03
Remove redirect when not required by the ProcessingChain
ioigoume Jun 24, 2024
fb7f643
push authSourceId to state before the ProcessingChain redirect
ioigoume Jun 24, 2024
036151b
fix psalm errors
ioigoume Jun 24, 2024
6859770
Merge branch 'SSP-2030_OIDC_module_switch_to_ProcessingChain_for_auth…
cicnavi Jun 27, 2024
f9a905d
Merge branch 'wip-version-6' into SSP-2030_OIDC_module_switch_to_Proc…
cicnavi Jun 27, 2024
8ef0d03
psaml issue
ioigoume Jun 27, 2024
4dc8323
test AuthenticationService::prepareState
ioigoume Jun 27, 2024
9f65162
fix psalm errors
ioigoume Jun 27, 2024
99576ae
change function visibility
ioigoume Jun 27, 2024
4c539b4
Extend AuthenticationServiceTest unit tests
ioigoume Jun 27, 2024
3fa7447
Add more tests.
ioigoume Jun 28, 2024
d281346
test AuthenticationServiceTest::RunAuthProcs
ioigoume Jun 28, 2024
650116d
Fix psalm errors
ioigoume Jun 28, 2024
0ab3afe
Add AuthenticationService tests
ioigoume Jun 29, 2024
9a8a756
Add missing dot
ioigoume Jun 29, 2024
f9b6bea
AuthenticationService::getAuthorizationRequestFromState tests
ioigoume Jun 29, 2024
07263af
AuthenticationServiceTest.php improvements
ioigoume Jun 30, 2024
feadf35
AuthorizationControllerTests::test invoke for queryParameters differe…
ioigoume Jul 3, 2024
17b750a
Add ProcessingChainFactory
ioigoume Jul 3, 2024
9991045
Add ProcessingChainFactory test class
ioigoume Jul 3, 2024
3819f38
Wrap SimpleSaml\Auth\State to a service
ioigoume Jul 4, 2024
d58f8f2
Wrap SimpleSaml\Auth\State to a service
ioigoume Jul 4, 2024
3c9c6d5
Wrap SimpleSaml\Auth\State to a service
ioigoume Jul 4, 2024
bd8df30
Wrap SimpleSaml\Auth\State to a service
ioigoume Jul 4, 2024
d450ad1
fix ambiquous getAuthorizationRequestFromState return value
ioigoume Jul 5, 2024
9fd8f79
Add some manual testing tips for authproc testing; run an authproc as…
pradtke Jul 10, 2024
d5e7997
Update documentation
pradtke Jul 11, 2024
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,16 @@ and you can add a client.

You may view the OIDC configuration endpoint at `https://localhost/.well-known/openid-configuration`

#### Testing AuthProc filters

To perform manual testing of authproc filters, enable the authprocs in `module_oidc.php` that set firstname, sn and performs
a redirect for preprod warning. This setup shows that an authproc can do a redirect and then processing resumes.
Once adjusted, run docker while change the `COMPOSER_REQUIRE` line to

`-e COMPOSER_REQUIRE="simplesamlphp/simplesamlphp-module-oidc:@dev simplesamlphp/simplesamlphp-module-preprodwarning" \`

You can register a client from https://oidcdebugger.com/ to test.

### Build Image to Deploy for Conformance Tests

Build an image that contains a pre-configured sqlite database.
Expand Down
2 changes: 2 additions & 0 deletions docker/ssp/config-override.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

$config['module.enable']['exampleauth'] = true;
$config['module.enable']['oidc'] = true;
// Have preprod warning enabled (though it may not be installed) to ease authproc redirect testing
$config['module.enable']['preprodwarning'] = true;
$config = [
'secretsalt' => 'testsalt',
'database.dsn' => 'sqlite:/var/simplesamlphp/data/mydb.sq3',
Expand Down
23 changes: 23 additions & 0 deletions docker/ssp/module_oidc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,31 @@
],

ModuleConfig::OPTION_AUTH_PROCESSING_FILTERS => [
// For conformance tests we always have an authproc run just to confirm nothing is broken
// with the integration to ProcessingChain
5 => [
'class' => 'core:AttributeAdd',
'someUnusedAttribute' => 'Some value',
]
],

// Use the below auth processing config to test authprocs with a redirect
/* ModuleConfig::OPTION_AUTH_PROCESSING_FILTERS => [
5 => [
'class' => 'core:AttributeAdd',
'%replace',
'givenName' => 'First AuthProc',
],
10 => [
'class' => 'preprodwarning:Warning',
],
15 => [
'class' => 'core:AttributeAdd',
'%replace',
'sn' => 'SN AuthProc',
]
],*/

ModuleConfig::OPTION_AUTH_CUSTOM_SCOPES => [
],
ModuleConfig::OPTION_AUTH_SAML_TO_OIDC_TRANSLATE_TABLE => [
Expand Down
26 changes: 24 additions & 2 deletions src/Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use League\OAuth2\Server\Exception\OAuthServerException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use SimpleSAML\Auth\ProcessingChain;
use SimpleSAML\Module\oidc\Bridges\PsrHttpBridge;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\Module\oidc\Server\AuthorizationServer;
Expand Down Expand Up @@ -56,9 +57,19 @@ public function __construct(
*/
public function __invoke(ServerRequestInterface $request): ResponseInterface
{
$authorizationRequest = $this->authorizationServer->validateAuthorizationRequest($request);
$queryParameters = $request->getQueryParams();
$state = null;

$user = $this->authenticationService->getAuthenticateUser($request);
if (!isset($queryParameters[ProcessingChain::AUTHPARAM])) {
$authorizationRequest = $this->authorizationServer->validateAuthorizationRequest($request);
$state = $this->authenticationService->processRequest($request, $authorizationRequest);
// processState will trigger a redirect
}

$state ??= $this->authenticationService->manageState($queryParameters);
$authorizationRequest = $this->authenticationService->getAuthorizationRequestFromState($state);

$user = $this->authenticationService->getAuthenticateUser($state);

$authorizationRequest->setUser($user);
$authorizationRequest->setAuthorizationApproved(true);
Expand All @@ -77,6 +88,17 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface
);
}

/**
* @param Request $request
*
* @return Response
* @throws \SimpleSAML\Error\AuthSource
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\Error
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\NotFound
* @throws \Throwable
*/
public function authorization(Request $request): Response
{
try {
Expand Down
45 changes: 45 additions & 0 deletions src/Factories/ProcessingChainFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

declare(strict_types=1);

/*
* This file is part of the simplesamlphp-module-oidc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace SimpleSAML\Module\oidc\Factories;

use SimpleSAML\Auth\ProcessingChain;
use SimpleSAML\Module\oidc\ModuleConfig;

class ProcessingChainFactory
{
public function __construct(
private readonly ModuleConfig $moduleConfig,
) {
}

/**
* @codeCoverageIgnore
* @throws \Exception
*/
public function build(array $state): ProcessingChain
{
$idpMetadata = [
'entityid' => $state['Source']['entityid'] ?? '',
// ProcessChain needs to know the list of authproc filters we defined in module_oidc configuration
'authproc' => $this->moduleConfig->getAuthProcFilters(),
];
$spMetadata = [
'entityid' => $state['Destination']['entityid'] ?? '',
];

return new ProcessingChain(
$idpMetadata,
$spMetadata,
'oidc',
);
}
}
116 changes: 0 additions & 116 deletions src/Services/AuthProcService.php

This file was deleted.

Loading