Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
Doorcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guardians of the Kretschmar Elock System
Doorcode
Commits
c49b75ce
Commit
c49b75ce
authored
Apr 05, 2020
by
Jacob Priddy
👌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readd simple saml php
parent
c5cce3cb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
69 deletions
+115
-69
docker-compose.yml.example
docker-compose.yml.example
+4
-4
src/web/backend/.gitignore
src/web/backend/.gitignore
+1
-0
src/web/backend/composer.json
src/web/backend/composer.json
+4
-3
src/web/backend/composer.lock
src/web/backend/composer.lock
+42
-1
src/web/backend/src/Gateways/Saml/SimpleSamlPhpSamlRepository.php
...backend/src/Gateways/Saml/SimpleSamlPhpSamlRepository.php
+4
-4
src/web/backend/src/UseCases/Users/Authenticate/Authenticate.php
.../backend/src/UseCases/Users/Authenticate/Authenticate.php
+58
-56
src/web/backend/src/UseCases/Users/Authenticate/AuthenticateUseCaseServiceProvider.php
...Users/Authenticate/AuthenticateUseCaseServiceProvider.php
+2
-1
No files found.
docker-compose.yml.example
View file @
c49b75ce
...
...
@@ -28,11 +28,11 @@ services:
- ./src/web:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
# Saml config
- ./simplesamlphp-1.18.
3
:/var/simplesamlphp
- ./simplesamlphp-1.18.
5
:/var/simplesamlphp
- ./simple-saml/cert:/var/simplesamlphp/cert
- ./simple-saml/config:/var/simplesamlphp/config
- ./simple-saml/metadata:/var/simplesamlphp/metadata
- ./simplesamlphp-1.18.
3
:/var/simplesamlphp-idp
- ./simplesamlphp-1.18.
5
:/var/simplesamlphp-idp
- ./simple-saml-idp/cert:/var/simplesamlphp-idp/cert
- ./simple-saml-idp/config:/var/simplesamlphp-idp/config
- ./simple-saml-idp/metadata:/var/simplesamlphp-idp/metadata
...
...
@@ -77,11 +77,11 @@ services:
- ./src/web:/var/www
- ./php/dev.ini:/usr/local/etc/php/conf.d/local.ini
# Map saml files to the php-fpm server so it has access to them as well
- ./simplesamlphp-1.18.
3
:/var/simplesamlphp
- ./simplesamlphp-1.18.
5
:/var/simplesamlphp
- ./simple-saml/cert:/var/simplesamlphp/cert
- ./simple-saml/config:/var/simplesamlphp/config
- ./simple-saml/metadata:/var/simplesamlphp/metadata
- ./simplesamlphp-1.18.
3
:/var/simplesamlphp-idp
- ./simplesamlphp-1.18.
5
:/var/simplesamlphp-idp
- ./simple-saml-idp/cert:/var/simplesamlphp-idp/cert
- ./simple-saml-idp/config:/var/simplesamlphp-idp/config
- ./simple-saml-idp/metadata:/var/simplesamlphp-idp/metadata
...
...
src/web/backend/.gitignore
View file @
c49b75ce
...
...
@@ -3,6 +3,7 @@
/public/storage
/storage/*.key
/vendor
/vendor-bin
.env
.env.backup
.phpunit.result.cache
...
...
src/web/backend/composer.json
View file @
c49b75ce
...
...
@@ -10,18 +10,19 @@
"require"
:
{
"php"
:
"^7.4"
,
"fideloper/proxy"
:
"^4.0"
,
"friendsofphp/php-cs-fixer"
:
"^2.16"
,
"fruitcake/laravel-cors"
:
"^1.0"
,
"laravel/framework"
:
"^7.0"
,
"laravel/tinker"
:
"^2.0"
},
"require-dev"
:
{
"roave/security-advisories"
:
"dev-master"
,
"bamarni/composer-bin-plugin"
:
"^1.3"
,
"friendsofphp/php-cs-fixer"
:
"^2.16"
,
"facade/ignition"
:
"^2.0"
,
"fzaninotto/faker"
:
"^1.4"
,
"mockery/mockery"
:
"^1.0"
,
"nunomaduro/collision"
:
"^4.1"
,
"phpunit/phpunit"
:
"^8.5"
"phpunit/phpunit"
:
"^8.5"
,
"roave/security-advisories"
:
"dev-master"
},
"config"
:
{
"optimize-autoloader"
:
true
,
...
...
src/web/backend/composer.lock
View file @
c49b75ce
...
...
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "
724d38cdc18fab793fe808f568c1cdde
",
"content-hash": "
cd2f50b50bd735add91a87d4abd9d3d7
",
"packages": [
{
"name": "asm89/stack-cors",
...
...
@@ -756,6 +756,7 @@
"email": "jakub.onderka@gmail.com"
}
],
"abandoned": "php-parallel-lint/php-console-color",
"time": "2018-09-29T17:23:10+00:00"
},
{
...
...
@@ -802,6 +803,7 @@
}
],
"description": "Highlight PHP code in terminal",
"abandoned": "php-parallel-lint/php-console-highlighter",
"time": "2018-09-29T18:48:56+00:00"
},
{
...
...
@@ -3697,6 +3699,45 @@
}
],
"packages-dev": [
{
"name": "bamarni/composer-bin-plugin",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/bamarni/composer-bin-plugin.git",
"reference": "67f9d314dc7ecf7245b8637906e151ccc62b8d24"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/67f9d314dc7ecf7245b8637906e151ccc62b8d24",
"reference": "67f9d314dc7ecf7245b8637906e151ccc62b8d24",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0"
},
"require-dev": {
"composer/composer": "dev-master",
"symfony/console": "^2.5 || ^3.0 || ^4.0"
},
"type": "composer-plugin",
"extra": {
"class": "Bamarni\\Composer\\Bin\\Plugin",
"branch-alias": {
"dev-master": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"Bamarni\\Composer\\Bin\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"time": "2019-03-17T12:38:04+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.3.0",
...
...
src/web/backend/src/Gateways/Saml/SimpleSamlPhpSamlRepository.php
View file @
c49b75ce
...
...
@@ -3,7 +3,7 @@
namespace
Source\Gateways\Saml
;
use
Exception
;
use
SimpleSAML_Auth_Simple
;
use
SimpleS
amlPHP\SimpleS
AML_Auth_Simple
;
use
Source\Entities\SamlUser
;
use
Illuminate\Support\Facades\Log
;
use
Illuminate\Support\Facades\Validator
;
...
...
@@ -17,11 +17,11 @@ class SimpleSamlPhpSamlRepository implements SamlRepository
protected
string
$logoutUrl
;
/**
* Found in simplesamlphp-1.18.
3
/lib/SimpleSAML/Auth/Simple.php
* Found in simplesamlphp-1.18.
5
/lib/SimpleSAML/Auth/Simple.php
*
* See https://simplesamlphp.org/docs/stable/simplesamlphp-sp-api for information on these methods
*
* @var SimpleSAML_Auth_Simple
* @var SimpleS
amlPHP\SimpleS
AML_Auth_Simple
* @method bool isAuthenticated()
* @method void requireAuth(array $params = [])
* @method void login(array $params = [])
...
...
@@ -50,7 +50,7 @@ class SimpleSamlPhpSamlRepository implements SamlRepository
require_once
base_path
(
$samlAutoloadPath
);
$this
->
saml
=
new
SimpleSAML_Auth_Simple
(
$authSource
);
$this
->
saml
=
new
SimpleS
amlPHP\SimpleS
AML_Auth_Simple
(
$authSource
);
}
/**
...
...
src/web/backend/src/UseCases/Users/Authenticate/Authenticate.php
View file @
c49b75ce
...
...
@@ -24,17 +24,19 @@ class Authenticate implements AuthenticateUseCase
*/
protected
TokensRepository
$tokens
;
//
/**
//
* @var \Source\Gateways\Saml\SamlRepository
//
*/
//
protected SamlRepository $saml;
/**
* @var \Source\Gateways\Saml\SamlRepository
*/
protected
SamlRepository
$saml
;
/**
* @param \Source\Gateways\Users\UsersRepository $users
* @param \Source\Gateways\Tokens\TokensRepository $tokens
* @param \Source\Gateways\Saml\SamlRepository $saml
*/
public
function
__construct
(
UsersRepository
$users
,
TokensRepository
$tokens
)
public
function
__construct
(
UsersRepository
$users
,
TokensRepository
$tokens
,
SamlRepository
$saml
)
{
$this
->
saml
=
$saml
;
$this
->
users
=
$users
;
$this
->
tokens
=
$tokens
;
}
...
...
@@ -80,8 +82,8 @@ class Authenticate implements AuthenticateUseCase
*/
public
function
handToSaml
(
array
$options
=
[]):
string
{
throw
new
NotImplementedException
();
//
return $this->saml->login($options);
//
throw new NotImplementedException();
return
$this
->
saml
->
login
(
$options
);
}
/**
...
...
@@ -90,49 +92,49 @@ class Authenticate implements AuthenticateUseCase
*/
public
function
handleSamlLogin
(
Presenter
$presenter
):
void
{
throw
new
NotImplementedException
();
//
$samlUser = $this->saml->handleLogin();
//
//
if (!$samlUser) {
//
throw new UserCreationException();
//
}
//
//
// First check to see if the user exists in the database.
//
$user = $this->users->findByEmail($samlUser->getEmail());
//
//
// If the user does not exist, create them.
//
if (!$user) {
//
$user = $this->users->create(
//
new User(
//
0,
//
$samlUser->getFirstName(),
//
$samlUser->getLastName(),
//
$samlUser->getDisplayName(),
//
$samlUser->getEmail(),
//
$samlUser->getEmplid(),
//
null,
//
null
//
)
//
);
//
}
//
//
if (!$user) {
//
throw new UserCreationException();
//
}
//
//
$token = $this->tokens->create(
//
new Token(
//
0,
//
$user->getId(),
//
Str::random(60),
//
null,
//
Carbon::now()->addDays(2)
//
)
//
);
//
//
$response = new ResponseModel($user, $token);
//
//
$presenter->present($response);
//
throw new NotImplementedException();
$samlUser
=
$this
->
saml
->
handleLogin
();
if
(
!
$samlUser
)
{
throw
new
UserCreationException
();
}
// First check to see if the user exists in the database.
$user
=
$this
->
users
->
findByEmail
(
$samlUser
->
getEmail
());
// If the user does not exist, create them.
if
(
!
$user
)
{
$user
=
$this
->
users
->
create
(
new
User
(
0
,
$samlUser
->
getFirstName
(),
$samlUser
->
getLastName
(),
$samlUser
->
getDisplayName
(),
$samlUser
->
getEmail
(),
$samlUser
->
getEmplid
(),
null
,
null
)
);
}
if
(
!
$user
)
{
throw
new
UserCreationException
();
}
$token
=
$this
->
tokens
->
create
(
new
Token
(
0
,
$user
->
getId
(),
Str
::
random
(
60
),
null
,
Carbon
::
now
()
->
addDays
(
2
)
)
);
$response
=
new
ResponseModel
(
$user
,
$token
);
$presenter
->
present
(
$response
);
}
/**
...
...
@@ -141,11 +143,11 @@ class Authenticate implements AuthenticateUseCase
*/
public
function
samlLogout
(
?string
$token
):
string
{
throw
new
NotImplementedException
();
//
if ($token) {
//
$this->tokens->invalidateToken($token);
//
}
//
//
return $this->saml->logout();
//
throw new NotImplementedException();
if
(
$token
)
{
$this
->
tokens
->
invalidateToken
(
$token
);
}
return
$this
->
saml
->
logout
();
}
}
src/web/backend/src/UseCases/Users/Authenticate/AuthenticateUseCaseServiceProvider.php
View file @
c49b75ce
...
...
@@ -25,7 +25,8 @@ class AuthenticateUseCaseServiceProvider extends ServiceProvider implements Defe
$this
->
app
->
bind
(
AuthenticateUseCase
::
class
,
static
function
(
Application
$app
)
{
return
new
Authenticate
(
$app
->
make
(
UsersRepository
::
class
),
$app
->
make
(
TokensRepository
::
class
)
$app
->
make
(
TokensRepository
::
class
),
$app
->
make
(
SamlRepository
::
class
)
);
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment