This repository was archived by the owner on Nov 14, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathRendersTenants.php
More file actions
95 lines (84 loc) · 3.01 KB
/
RendersTenants.php
File metadata and controls
95 lines (84 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Slides\Saml2\Commands;
use Slides\Saml2\Models\Tenant;
use Illuminate\Support\Str;
/**
* Class CreateTenant
*
* @package Slides\Saml2\Commands
*/
trait RendersTenants
{
/**
* Render tenants in a table.
*
* @param \Slides\Saml2\Models\Tenant|\Illuminate\Support\Collection $tenants
* @param string|null $title
*
* @return void
*/
protected function renderTenants($tenants, string $title = null)
{
/** @var \Slides\Saml2\Models\Tenant[]|\Illuminate\Database\Eloquent\Collection $tenants */
$tenants = $tenants instanceof Tenant
? collect([$tenants])
: $tenants;
$headers = ['Column', 'Value'];
$columns = [];
foreach ($tenants as $tenant) {
foreach ($this->getTenantColumns($tenant) as $column => $value) {
$columns[] = [$column, $value ?: '(empty)'];
}
if($tenants->last()->id !== $tenant->id) {
$columns[] = new \Symfony\Component\Console\Helper\TableSeparator();
}
}
if($title) {
$this->getOutput()->title($title);
}
$this->table($headers, $columns);
}
/**
* Get a columns of the Tenant.
*
* @param \Slides\Saml2\Models\Tenant $tenant
*
* @return array
*/
protected function getTenantColumns(Tenant $tenant)
{
return [
'ID' => $tenant->id,
'UUID' => $tenant->uuid,
'Key' => $tenant->key,
'Entity ID' => $tenant->idp_entity_id,
'Login URL' => $tenant->idp_login_url,
'Logout URL' => $tenant->idp_logout_url,
'Relay State URL' => $tenant->relay_state_url,
'Name ID format' => $tenant->name_id_format,
'x509 cert' => Str::limit($tenant->idp_x509_cert, 50),
'Metadata' => print_r($tenant->metadata ?: [],1),
'Created' => $tenant->created_at->toDateTimeString(),
'Updated' => $tenant->updated_at->toDateTimeString(),
'Deleted' => $tenant->deleted_at ? $tenant->deleted_at->toDateTimeString() : null
];
}
/**
* Render a tenant credentials.
*
* @param \Slides\Saml2\Models\Tenant $tenant
*
* @return void
*/
protected function renderTenantCredentials(Tenant $tenant)
{
$this->output->section('Credentials for the tenant');
$this->getOutput()->text([
'Identifier (Entity ID): <comment>' . route('saml.metadata', ['uuid' => $tenant->uuid]) . '</comment>',
'Reply URL (Assertion Consumer Service URL): <comment>' . route('saml.acs', ['uuid' => $tenant->uuid]) . '</comment>',
'Sign on URL: <comment>' . route('saml.login', ['uuid' => $tenant->uuid]) . '</comment>',
'Logout URL: <comment>' . route('saml.logout', ['uuid' => $tenant->uuid]) . '</comment>',
'Relay State: <comment>' . ($tenant->relay_state_url ?: config('saml2.loginRoute')) . ' (optional)</comment>'
]);
}
}