-
Notifications
You must be signed in to change notification settings - Fork 26
Feature: Add SRAM integration #1819
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
Open
johanib
wants to merge
23
commits into
main
Choose a base branch
from
feature/sram-interrupt_rebase
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e87c152
Add SRAM Testfilter
mrvanes 81e1f7c
Add sbs-stub
mrvanes 3ba3ff5
Change the ValidateAllowedConnection input filter so that collab_enab…
johanib b9bdd9a
Implement sbs integration flow
johanib d4f8dbd
Several fixes
mrvanes 2b6ca81
WIP
mrvanes 95d4552
Adjust SBS flow integration test to updated specs
johanib e9100ba
Add SBS message logging
mrvanes 9feb1b4
Use collabPersonId for sbs user_id
mrvanes 97189e2
Add SHO and EPPN to SBS authz call
mrvanes 23582e0
Add message to sbs authz response
mrvanes fc40910
Fix tests
mrvanes 063f963
Reinstate attributes endpoint
mrvanes 622eab7
Rename entitlements to attributes
mrvanes ea9a241
Better SBS interrupt reason logging
mrvanes e901c79
Reinstate attributes endpoint test
mrvanes 49c5eaf
Refactoring attempt
mrvanes 36e34da
SRAM enabled false by default
mrvanes 043e203
Fix SRAM RP entityId behind oidcng trusted proxy
mrvanes df1777a
Fix SRAMInterruptFilterTest
mrvanes b09292a
Make sure sram.base_url always ends with a /
baszoetekouw f7e2cd8
Improve SBS response debugging
mrvanes a81a69d
Don't restart test mariadb container
mrvanes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
library/EngineBlock/Corto/Filter/Command/SRAMInterruptFilter.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?php | ||
|
|
||
| use OpenConext\EngineBlockBundle\Configuration\FeatureConfigurationInterface; | ||
| use OpenConext\EngineBlockBundle\Exception\InvalidSbsResponseException; | ||
| use OpenConext\EngineBlockBundle\Sbs\Dto\AuthzRequest; | ||
| use OpenConext\EngineBlockBundle\Sbs\SbsAttributeMerger; | ||
|
|
||
| /** | ||
| * Copyright 2021 Stichting Kennisnet | ||
| * | ||
| * Licensed 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. | ||
| */ | ||
|
|
||
| class EngineBlock_Corto_Filter_Command_SRAMInterruptFilter extends EngineBlock_Corto_Filter_Command_Abstract | ||
| implements EngineBlock_Corto_Filter_Command_ResponseAttributesModificationInterface | ||
| { | ||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function getResponseAttributes() | ||
| { | ||
| return $this->_responseAttributes; | ||
| } | ||
|
|
||
| public function getResponse() | ||
| { | ||
| return $this->_response; | ||
| } | ||
|
|
||
| public function execute(): void | ||
| { | ||
| $log = EngineBlock_ApplicationSingleton::getLog(); | ||
|
|
||
| if (!$this->getFeatureConfiguration()->isEnabled('eb.feature_enable_sram_interrupt')) { | ||
| return; | ||
| } | ||
|
|
||
| if ($this->_serviceProvider->getCoins()->collabEnabled() === false) { | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| $request = $this->buildRequest(); | ||
|
|
||
| $interruptResponse = $this->getSbsClient()->authz($request); | ||
|
|
||
| if ($interruptResponse->msg === 'interrupt') { | ||
| $log->info("SBS interrupt reason: " . $interruptResponse->message); | ||
| $this->_response->setSRAMInterruptNonce($interruptResponse->nonce); | ||
| } elseif ($interruptResponse->msg === 'authorized' && !empty($interruptResponse->attributes)) { | ||
| $this->_responseAttributes = $this->getSbsAttributeMerger()->mergeAttributes($this->_responseAttributes, $interruptResponse->attributes); | ||
| } else { | ||
| throw new InvalidSbsResponseException(sprintf('Invalid SBS response received: %s', $interruptResponse->msg)); | ||
| } | ||
| } catch (Throwable $e){ | ||
| throw new EngineBlock_Exception_SbsCheckFailed('The SBS server could not be queried: ' . $e->getMessage()); | ||
| } | ||
| } | ||
|
|
||
| private function getSbsClient() | ||
| { | ||
| return EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getSbsClient(); | ||
| } | ||
|
|
||
| private function getFeatureConfiguration(): FeatureConfigurationInterface | ||
| { | ||
| return EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getFeatureConfiguration(); | ||
| } | ||
|
|
||
| private function getSbsAttributeMerger(): SbsAttributeMerger | ||
| { | ||
| return EngineBlock_ApplicationSingleton::getInstance()->getDiContainer()->getSbsAttributeMerger(); | ||
| } | ||
|
|
||
| /** | ||
| * @return AuthzRequest | ||
| * @throws EngineBlock_Corto_ProxyServer_Exception | ||
| */ | ||
| private function buildRequest(): AuthzRequest | ||
| { | ||
| $attributes = $this->getResponseAttributes(); | ||
| $id = $this->_request->getId(); | ||
|
|
||
| $user_id = $this->_collabPersonId ?? ""; | ||
| $eppn = $attributes['urn:mace:dir:attribute-def:eduPersonPrincipalName'][0] ?? ""; | ||
| $continue_url = $this->_server->getUrl('SRAMInterruptService', '') . "?ID=$id"; | ||
| $service_id = $this->_serviceProvider->entityId; | ||
| $issuer_id = $this->_identityProvider->entityId; | ||
|
|
||
| return AuthzRequest::create( | ||
| $user_id, | ||
| $eppn, | ||
| $continue_url, | ||
| $service_id, | ||
| $issuer_id | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.