1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace rhertogh\Yii2Oauth2Server\controllers\console\client; |
4
|
|
|
|
5
|
|
|
use rhertogh\Yii2Oauth2Server\controllers\console\client\base\Oauth2BaseClientAction; |
6
|
|
|
use rhertogh\Yii2Oauth2Server\controllers\console\Oauth2ClientController; |
7
|
|
|
use rhertogh\Yii2Oauth2Server\interfaces\models\Oauth2ClientInterface; |
8
|
|
|
use rhertogh\Yii2Oauth2Server\Oauth2Module; |
9
|
|
|
use yii\console\ExitCode; |
10
|
|
|
use yii\console\widgets\Table; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @property Oauth2ClientController $controller |
14
|
|
|
*/ |
15
|
|
|
class Oauth2ViewClientAction extends Oauth2BaseClientAction |
16
|
|
|
{ |
17
|
|
|
public function run($id) |
18
|
|
|
{ |
19
|
|
|
$module = $this->controller->module; |
20
|
|
|
$client = $this->findByIdOrIdentifier($id); |
21
|
|
|
|
22
|
|
|
$clientInfo = [ |
23
|
|
|
'ID' => $client->getPrimaryKey(), |
24
|
|
|
'Identifier' => $client->getIdentifier(), |
|
|
|
|
25
|
|
|
'Name' => $client->getName(), |
|
|
|
|
26
|
|
|
'Type' => $client->isConfidential() ? 'Confidential' : 'Public', |
|
|
|
|
27
|
|
|
'Redirect URIs' => implode(', ', $client->getRedirectUri()), |
|
|
|
|
28
|
|
|
'Allow Variable URI Query' => $client->isVariableRedirectUriQueryAllowed() ? 'Yes' : 'No', |
|
|
|
|
29
|
|
|
'Grant Types' => implode(',', Oauth2Module::getGrantTypeIdentifiers($client->getGrantTypes())), |
|
|
|
|
30
|
|
|
'Scope Access' => Oauth2ClientInterface::SCOPE_ACCESSES_LABELS[$client->getScopeAccess()], |
|
|
|
|
31
|
|
|
'End Users may authorize client' => $client->endUsersMayAuthorizeClient() ? 'Yes' : 'No', |
|
|
|
|
32
|
|
|
'User Account Selection' => $client->getUserAccountSelection() |
|
|
|
|
33
|
|
|
? Oauth2Module::USER_ACCOUNT_SELECTION_NAMES[$client->getUserAccountSelection()] |
34
|
|
|
: '[Using default: ' |
35
|
|
|
. Oauth2Module::USER_ACCOUNT_SELECTION_NAMES[$module->defaultUserAccountSelection] |
36
|
|
|
. ']', |
37
|
|
|
'Is Auth Code without PKCE allowed' => $client->isAuthCodeWithoutPkceAllowed() ? 'Yes' : 'No', |
|
|
|
|
38
|
|
|
'Skip authorization if scope is allowed' => $client->skipAuthorizationIfScopeIsAllowed() ? 'Yes' : 'No', |
|
|
|
|
39
|
|
|
'Logo URI' => $client->getLogoUri(), |
|
|
|
|
40
|
|
|
'Terms of Service URI' => $client->getTermsOfServiceUri(), |
|
|
|
|
41
|
|
|
'Contacts' => $client->getContacts(), |
|
|
|
|
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
if ($client->validateGrantType(Oauth2Module::GRANT_TYPE_IDENTIFIER_CLIENT_CREDENTIALS)) { |
|
|
|
|
45
|
|
|
$clientInfo['Client Credentials Grant User'] = $client->getClientCredentialsGrantUserId(); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
if ($module->enableOpenIdConnect) { |
49
|
|
|
$clientInfo['OIDC allow offline access without consent'] = |
50
|
|
|
$client->getOpenIdConnectAllowOfflineAccessWithoutConsent() ? 'Yes' : 'No'; |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$clientInfo['Enabled'] = $client->isEnabled() ? 'Yes' : 'No'; |
|
|
|
|
54
|
|
|
|
55
|
|
|
$this->controller->stdout(Table::widget([ |
56
|
|
|
'rows' => array_map(fn($property) => [$property, $clientInfo[$property]], array_keys($clientInfo)), |
57
|
|
|
])); |
58
|
|
|
|
59
|
|
|
return ExitCode::OK; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|