| Conditions | 5 |
| Paths | 16 |
| Total Lines | 60 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 110 | * @return \SimpleSAML\HTTP\RunnableResponse A Symfony Response-object. |
||
| 111 | */ |
||
| 112 | public function main(/** @scrutinizer ignore-unused */ Request $request): RunnableResponse |
||
| 113 | { |
||
| 114 | $moduleConfig = Configuration::getOptionalConfig('module_webauthn.php'); |
||
| 115 | $registrationConfig = $moduleConfig->getArray('registration'); |
||
| 116 | $registrationAuthSource = $registrationConfig['auth_source'] ?? 'default-sp'; |
||
| 117 | |||
| 118 | /** @psalm-var class-string $authSimple */ |
||
| 119 | $authSimple = $this->authSimple; |
||
| 120 | $as = new $authSimple($registrationAuthSource); |
||
| 121 | $as->requireAuth(); |
||
| 122 | $attrs = $as->getAttributes(); |
||
| 123 | |||
| 124 | $state = []; |
||
| 125 | $state['Attributes'] = $attrs; |
||
| 126 | |||
| 127 | $stateData = new StateData(); |
||
| 128 | $stateData->requestTokenModel = ($registrationConfig['policy_2fa']['minimum_certification_level'] == "0" ? false : true); |
||
| 129 | $stateData->minCertLevel2FA = $registrationConfig['policy_2fa']['minimum_certification_level']; |
||
| 130 | $stateData->aaguidWhitelist2FA = $registrationConfig['policy_2fa']['aaguid_whitelist']; |
||
| 131 | $stateData->attFmtWhitelist2FA = $registrationConfig['policy_2fa']['attestation_format_whitelist']; |
||
| 132 | $stateData->minCertLevelPasswordless = $registrationConfig['policy_passwordless']['minimum_certification_level']; |
||
| 133 | $stateData->aaguidWhitelistPasswordless = $registrationConfig['policy_passwordless']['aaguid_whitelist']; |
||
| 134 | $stateData->attFmtWhitelistPasswordless = $registrationConfig['policy_passwordless']['attestation_format_whitelist']; |
||
| 135 | $stateData->requestTokenModel = ($registrationConfig['minimum_certification_level'] == "0" ? false : true); |
||
| 136 | $stateData->minCertLevel = $registrationConfig['minimum_certification_level']; |
||
| 137 | $stateData->aaguidWhitelist = $registrationConfig['aaguid_whitelist']; |
||
| 138 | $stateData->attFmtWhitelist = $registrationConfig['attestation_format_whitelist']; |
||
| 139 | |||
| 140 | >>>>>>> 9acf80d (Fix codesniffer issues) |
||
|
|
|||
| 141 | try { |
||
| 142 | $stateData->store = Store::parseStoreConfig($moduleConfig->getArray('store')); |
||
| 143 | } catch (Exception $e) { |
||
| 144 | $this->logger::error( |
||
| 145 | 'webauthn: Could not create storage: ' . $e->getMessage() |
||
| 146 | ); |
||
| 147 | } |
||
| 148 | |||
| 149 | $stateData->scope = $moduleConfig->getOptionalString('scope', null); |
||
| 150 | $httpUtils = new Utils\HTTP(); |
||
| 151 | $baseurl = $httpUtils->getSelfHost(); |
||
| 152 | $hostname = parse_url($baseurl, PHP_URL_HOST); |
||
| 153 | if ($hostname !== null) { |
||
| 154 | $stateData->derivedScope = $hostname; |
||
| 155 | } |
||
| 156 | $stateData->usernameAttrib = $moduleConfig->getString('identifyingAttribute'); |
||
| 157 | $stateData->displaynameAttrib = $moduleConfig->getString('attrib_displayname'); |
||
| 158 | |||
| 159 | StaticProcessHelper::prepareState($stateData, $state); |
||
| 160 | |||
| 161 | $metadataHandler = MetaDataStorageHandler::getMetadataHandler(); |
||
| 162 | $metadata = $metadataHandler->getMetaDataCurrent('saml20-idp-hosted'); |
||
| 163 | $state['Source'] = $metadata; |
||
| 164 | $state['IdPMetadata'] = $metadata; |
||
| 165 | // inflow users are not allowed to enter the Registration page. If they |
||
| 166 | // did, kill the session |
||
| 167 | $moduleConfig = Configuration::getOptionalConfig('module_webauthn.php')->toArray(); |
||
| 168 | |||
| 169 | if ($moduleConfig['registration']['use_inflow_registration']) { |
||
| 170 | throw new Exception("Attempt to access the stand-alone registration page in inflow mode!"); |
||
| 179 |