Skip to content

Commit

Permalink
WIP First Symfony route
Browse files Browse the repository at this point in the history
  • Loading branch information
cicnavi committed Oct 24, 2023
1 parent 290bfdb commit 0a97379
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

## Medium impact changes
- TODO move to SSP (symfony) routing
- TODO handle CORS
- Module config options in file 'module_oidc.php' are now using constants for config keys. The values for constants are
taken from the previous version of the module, so theoretically you don't have to rewrite your current config file,
although it is recommended to do so.
Expand Down
2 changes: 1 addition & 1 deletion routing/routes/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
# controllerClassname: SimpleSAML\Module\oidc\Controller\Client\IndexController

openid-configuration:
path: openid/configuration
path: openid-configuration
controller: SimpleSAML\Module\oidc\Controller\ConfigurationDiscoveryController
22 changes: 18 additions & 4 deletions routing/services/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface: '@SimpleSAML\Module\oidc\Repositories\AccessTokenRepository'
League\OAuth2\Server\Repositories\ScopeRepositoryInterface: '@SimpleSAML\Module\oidc\Repositories\ScopeRepository'
League\OAuth2\Server\CryptKey|string $privateKey: '@oidc.key.private'
League\OAuth2\Server\CryptKey|string $publicKey: '@oidc.key.public'

SimpleSAML\Module\oidc\Services\:
resource: '../../src/Services/*'
Expand All @@ -25,16 +26,29 @@ services:
SimpleSAML\Module\oidc\Stores\:
resource: '../../src/Stores/*'

League\OAuth2\Server\ResourceServer: ~

SimpleSAML\Module\oidc\Utils\ClaimTranslatorExtractor: ~

SimpleSAML\Module\oidc\ModuleConfig: ~

oidc.key.private:
class: League\OAuth2\Server\CryptKey
factory: ['@SimpleSAML\Module\oidc\Factories\CryptKeyFactory', 'buildPrivateKey']

oidc.key.public:
class: League\OAuth2\Server\CryptKey
factory: ['@SimpleSAML\Module\oidc\Factories\CryptKeyFactory', 'buildPublicKey']

SimpleSAML\Module\oidc\Factories\ResourceServerFactory:
arguments:
$publicKey: '@oidc.key.public'

SimpleSAML\Module\oidc\Utils\ClaimTranslatorExtractor:
arguments:
$userIdAttr: '@=service("SimpleSAML\\Module\\oidc\\ModuleConfig").getUserIdentifierAttribute()'

SimpleSAML\Module\oidc\Server\AuthorizationServer:
arguments:
$encryptionKey: '@=service("SimpleSAML\\Module\\oidc\\ModuleConfig").getEncryptionKey()'

# OAuth2 Server
League\OAuth2\Server\ResourceServer:
arguments:
$publicKey: '@oidc.key.public'
2 changes: 1 addition & 1 deletion src/Controller/ConfigurationDiscoveryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

namespace SimpleSAML\Module\oidc\Controller;

use Laminas\Diactoros\Response\JsonResponse;
use SimpleSAML\Module\oidc\Services\OpMetadataService;
use Symfony\Component\HttpFoundation\JsonResponse;

class ConfigurationDiscoveryController
{
Expand Down
2 changes: 1 addition & 1 deletion src/Factories/ClaimTranslatorExtractorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function build(): ClaimTranslatorExtractor
}
}

$userIdAttr = $this->moduleConfig->config()->getString(ModuleConfig::OPTION_AUTH_USER_IDENTIFIER_ATTRIBUTE);
$userIdAttr = $this->moduleConfig->getUserIdentifierAttribute();

return new ClaimTranslatorExtractor($userIdAttr, $claimSet, $translatorTable, $allowedMultipleValueClaims);
}
Expand Down
8 changes: 8 additions & 0 deletions src/ModuleConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,12 @@ public function getForcedAcrValueForCookieAuthentication(): ?string

return (string) $value;
}

/**
* @throws Exception
*/
public function getUserIdentifierAttribute(): string
{
return $this->config()->getString(ModuleConfig::OPTION_AUTH_USER_IDENTIFIER_ATTRIBUTE);
}
}
2 changes: 1 addition & 1 deletion src/Services/AuthContextService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function isSspAdmin(): bool
public function getAuthUserId(): string
{
$simple = $this->authenticate();
$userIdAttr = $this->moduleConfig->config()->getString(ModuleConfig::OPTION_AUTH_USER_IDENTIFIER_ATTRIBUTE);
$userIdAttr = $this->moduleConfig->getUserIdentifierAttribute();
return (string)(new Attributes())->getExpectedAttribute($simple->getAttributes(), $userIdAttr);
}

Expand Down

0 comments on commit 0a97379

Please sign in to comment.