Merge branch 'develop' into trunk
This commit is contained in:
commit
74600ef3a7
7 changed files with 133 additions and 13 deletions
|
|
@ -47,9 +47,3 @@ LDC_WEB_CIDR_MANUAL_ALLOWED_LIST=
|
|||
# GITLAB API
|
||||
GITLAB_URL=
|
||||
GITLAB_TOKEN=
|
||||
|
||||
# SAML IDP
|
||||
## URL list separated by comma
|
||||
SAML_SP_URL_LIST=""
|
||||
## json sp config
|
||||
SAML_SP_CONFIG=''
|
||||
|
|
|
|||
42
app/Interfaces/SpsConfigInterface.php
Normal file
42
app/Interfaces/SpsConfigInterface.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Interfaces;
|
||||
|
||||
interface SpsConfigInterface
|
||||
{
|
||||
/**
|
||||
* URL method
|
||||
* Website (SP) url ex: https://le-gaulois-pro.s-web.test
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url(): string;
|
||||
/**
|
||||
* acsBase64 method
|
||||
* Return destination url base64 encoded
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function acsBase64(): string;
|
||||
/**
|
||||
* destination method
|
||||
* Return acs url concatenated with url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function destination(): string;
|
||||
/**
|
||||
* logout method
|
||||
* Return sls url concatenated with url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function logout(): string;
|
||||
/**
|
||||
* certificate method
|
||||
* Return certificate (.pem) file from kebab case of Enum name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function certificate(): string;
|
||||
}
|
||||
52
app/Traits/Enums/SpsConfigTrait.php
Normal file
52
app/Traits/Enums/SpsConfigTrait.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace App\Traits\Enums;
|
||||
|
||||
trait SpsConfigTrait
|
||||
{
|
||||
/**
|
||||
* acsBase64 method
|
||||
* Return destination url base64 encoded
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function acsBase64(): string
|
||||
{
|
||||
return base64_encode($this->destination());
|
||||
}
|
||||
/**
|
||||
* destination method
|
||||
* Return acs url concatenated with url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function destination(): string
|
||||
{
|
||||
return $this->url() . "/saml2/support/acs";
|
||||
}
|
||||
/**
|
||||
* logout method
|
||||
* Return sls url concatenated with url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function logout(): string
|
||||
{
|
||||
return $this->url() . "/saml2/support/sls";
|
||||
}
|
||||
/**
|
||||
* certificate method
|
||||
* Return certificate (.pem) file from kebab case of Enum name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function certificate(): string
|
||||
{
|
||||
return 'file://' . storage_path(
|
||||
sprintf(
|
||||
'samlidp/%s.pem',
|
||||
str()->kebab($this->name)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
<?php
|
||||
|
||||
$saml_sp_list = explode(",", env('SAML_SP_URL_LIST', []));
|
||||
foreach ($saml_sp_list as $sp) {
|
||||
$sp_slo_redirects[$sp] = $sp;
|
||||
$config = require_once(storage_path('samlidp/config.php'));
|
||||
|
||||
foreach (SpsEnum::cases() as $sp) {
|
||||
$sp_slo_redirects[$sp->url()] = $sp->url();
|
||||
$sp_configs[$sp->acsBase64()] = [
|
||||
'destination' => $sp->destination(),
|
||||
'logout' => $sp->logout(),
|
||||
'certificate' => $sp->certificate()
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
@ -55,7 +61,7 @@ return [
|
|||
// 'encrypt_assertion' => false
|
||||
// ].
|
||||
// ],.
|
||||
'sp' => json_decode(env('SAML_SP_CONFIG', "{}"), true),
|
||||
'sp' => $sp_configs,
|
||||
|
||||
// If you need to redirect after SLO depending on SLO initiator
|
||||
// Key is beginning of HTTP_REFERER value from SERVER, value is redirect path.
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ data:
|
|||
SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}"
|
||||
GITLAB_URL: "https://${CI_SERVER_HOST}"
|
||||
GITLAB_TOKEN: "${APP_GITLAB_TOKEN}"
|
||||
SAML_SP_URL_LIST: "${APP_SAML_SP_URL_LIST}"
|
||||
SAML_SP_CONFIG: "${APP_SAML_SP_CONFIG}"
|
||||
|
||||
---
|
||||
apiVersion: v1
|
||||
|
|
|
|||
|
|
@ -89,7 +89,10 @@ Route::middleware('admin-secure')
|
|||
// * TICKETS
|
||||
Route::get('/tickets/json/paginate', [TicketController::class, 'jsonPaginate'])
|
||||
->name('tickets.json-paginate');
|
||||
Route::post('/ticket/{ticket}/create-issue', [TicketController::class, 'createGitlabIssue'])
|
||||
Route::post(
|
||||
'/ticket/{ticket}/create-issue',
|
||||
[TicketController::class, 'createGitlabIssue']
|
||||
)
|
||||
->middleware('can:createGitlabIssue,ticket')
|
||||
->name('ticket.create-issue');
|
||||
});
|
||||
|
|
|
|||
25
storage/samlidp/config.php
Normal file
25
storage/samlidp/config.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use App\Interfaces\SpsConfigInterface;
|
||||
use App\Traits\Enums\SpsConfigTrait;
|
||||
|
||||
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
|
||||
enum SpsEnum implements SpsConfigInterface
|
||||
{
|
||||
use SpsConfigTrait;
|
||||
|
||||
case LeGauloisPro;
|
||||
|
||||
/**
|
||||
* URL method
|
||||
* Website url ex: https://le-gaulois-pro.s-web.test
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url(): string
|
||||
{
|
||||
return match ($this) {
|
||||
SpsEnum::LeGauloisPro => 'https://le-gaulois-pro.s-web.test'
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue