Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Commands/CreateTenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CreateTenant extends \Illuminate\Console\Command
{ --relayStateUrl= : Redirection URL after successful login }
{ --nameIdFormat= : Name ID Format ("persistent" by default) }
{ --x509cert= : x509 certificate (base64) }
{ --metadata= : A custom metadata }';
{ --metadata= : A custom metadata (JSON) }';

/**
* The console command description.
Expand Down Expand Up @@ -82,7 +82,7 @@ public function handle()
}

$key = $this->option('key');
$metadata = ConsoleHelper::stringToArray($this->option('metadata'));
$metadata = $this->option('metadata') ? \json_encode($this->option('metadata')) : '[]';

if($key && ($tenant = $this->tenants->findByKey($key))) {
$this->renderTenants($tenant, 'Already found tenant(s) using this key');
Expand Down
20 changes: 1 addition & 19 deletions src/Commands/RendersTenants.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ protected function getTenantColumns(Tenant $tenant)
'Relay State URL' => $tenant->relay_state_url,
'Name ID format' => $tenant->name_id_format,
'x509 cert' => Str::limit($tenant->idp_x509_cert, 50),
'Metadata' => $this->renderArray($tenant->metadata ?: []),
'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
Expand All @@ -92,22 +92,4 @@ protected function renderTenantCredentials(Tenant $tenant)
'Relay State: <comment>' . ($tenant->relay_state_url ?: config('saml2.loginRoute')) . ' (optional)</comment>'
]);
}

/**
* Print an array to a string.
*
* @param array $array
*
* @return string
*/
protected function renderArray(array $array)
{
$lines = [];

foreach ($array as $key => $value) {
$lines[] = "$key: $value";
}

return implode(PHP_EOL, $lines);
}
}
13 changes: 11 additions & 2 deletions src/Commands/UpdateTenant.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UpdateTenant extends \Illuminate\Console\Command
{ --relayStateUrl= : Redirection URL after successful login }
{ --nameIdFormat= : Name ID Format ("persistent" by default) }
{ --x509cert= : x509 certificate (base64) }
{ --metadata= : A custom metadata }';
{ --metadata= : A custom metadata (JSON format) }';

/**
* The console command description.
Expand Down Expand Up @@ -65,6 +65,15 @@ public function handle()
return;
}

$metadata = null;
if ($this->option('metadata')) {
$metadata = $this->option('metadata') ? \json_decode($this->option('metadata')) : null;
if (($json_error = \json_last_error_msg()) !== 'No error') {
$this->error($json_error);
return;
}
}

$tenant->update(array_filter([
'key' => $this->option('key'),
'idp_entity_id' => $this->option('entityId'),
Expand All @@ -73,7 +82,7 @@ public function handle()
'idp_x509_cert' => $this->option('x509cert'),
'relay_state_url' => $this->option('relayStateUrl'),
'name_id_format' => $this->resolveNameIdFormat(),
'metadata' => ConsoleHelper::stringToArray($this->option('metadata'))
'metadata' => $metadata,
]));

if(!$tenant->save()) {
Expand Down