Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dbp-relay-base-person-connector-ldap-bundle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Relay API Gateway
dbp-relay-base-person-connector-ldap-bundle
Commits
ae233e20
Unverified
Commit
ae233e20
authored
3 years ago
by
Bekerle, Patrizio
Browse files
Options
Downloads
Patches
Plain Diff
Remove PersonForExternalServiceEvent
parent
15a95410
No related branches found
No related tags found
No related merge requests found
Pipeline
#92541
failed
2 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+0
-56
0 additions, 56 deletions
README.md
src/Service/LDAPApi.php
+0
-15
0 additions, 15 deletions
src/Service/LDAPApi.php
src/Service/LDAPPersonProvider.php
+0
-5
0 additions, 5 deletions
src/Service/LDAPPersonProvider.php
tests/PersonTest.php
+0
-11
0 additions, 11 deletions
tests/PersonTest.php
with
0 additions
and
87 deletions
README.md
+
0
−
56
View file @
ae233e20
...
@@ -93,62 +93,6 @@ class PersonUserItemSubscriber implements EventSubscriberInterface
...
@@ -93,62 +93,6 @@ class PersonUserItemSubscriber implements EventSubscriberInterface
}
}
```
```
### PersonForExternalServiceEvent
Some integration services may need to fetch a person from an external API with a
`\Dbp\Relay\BasePersonBundle\API\PersonProviderInterface`
, for example:
```
php
$person
=
$this
->
personProvider
->
getPersonForExternalService
(
'SOME_SERVICE'
,
$userId
);
```
To implement such a fetch process from an external API this event can be used.
An event subscriber receives a
`\Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonForExternalServiceEvent`
instance
in a service for example in
`src/EventSubscriber/PersonForExternalServiceSubscriber.php`
:
```
php
<?php
namespace
App\EventSubscriber
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonForExternalServiceEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Service\LDAPApi
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
App\Service\ExternalApi
;
class
PersonForExternalServiceSubscriber
implements
EventSubscriberInterface
{
private
$ldap
;
private
$externalApi
;
public
function
__construct
(
LDAPApi
$ldap
,
ExternalApi
$externalApi
)
{
$this
->
ldap
=
$ldap
;
$this
->
externalApi
=
$externalApi
;
}
public
static
function
getSubscribedEvents
():
array
{
return
[
PersonForExternalServiceEvent
::
NAME
=>
'onEvent'
,
];
}
public
function
onEvent
(
PersonForExternalServiceEvent
$event
)
{
$service
=
$event
->
getService
();
$serviceID
=
$event
->
getServiceID
();
if
(
$service
===
'SOME_SERVICE'
)
{
$user
=
$this
->
externalApi
->
getPersonUserItemByExternalUserId
(
$serviceID
);
$person
=
$this
->
ldap
->
personFromUserItem
(
$user
,
true
);
$event
->
setPerson
(
$person
);
}
}
}
```
### PersonFromUserItemPostEvent
### PersonFromUserItemPostEvent
This event allows to modify the person after it is converted from an LDAP User.
This event allows to modify the person after it is converted from an LDAP User.
...
...
This diff is collapsed.
Click to expand it.
src/Service/LDAPApi.php
+
0
−
15
View file @
ae233e20
...
@@ -15,7 +15,6 @@ use Adldap\Connections\ProviderInterface;
...
@@ -15,7 +15,6 @@ use Adldap\Connections\ProviderInterface;
use
Adldap\Models\User
;
use
Adldap\Models\User
;
use
Adldap\Query\Builder
;
use
Adldap\Query\Builder
;
use
Dbp\Relay\BasePersonBundle\Entity\Person
;
use
Dbp\Relay\BasePersonBundle\Entity\Person
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonForExternalServiceEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonFromUserItemPostEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonFromUserItemPostEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonFromUserItemPreEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonFromUserItemPreEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonUserItemPreEvent
;
use
Dbp\Relay\BasePersonConnectorLdapBundle\Event\PersonUserItemPreEvent
;
...
@@ -29,7 +28,6 @@ use Psr\Log\LoggerAwareTrait;
...
@@ -29,7 +28,6 @@ use Psr\Log\LoggerAwareTrait;
use
Symfony\Component\Cache\Psr16Cache
;
use
Symfony\Component\Cache\Psr16Cache
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\HttpKernel\Exception\BadRequestHttpException
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Contracts\Service\ServiceSubscriberInterface
;
use
Symfony\Contracts\Service\ServiceSubscriberInterface
;
...
@@ -285,19 +283,6 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
...
@@ -285,19 +283,6 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
return
$person
;
return
$person
;
}
}
public
function
getPersonForExternalService
(
string
$service
,
string
$serviceID
):
Person
{
$event
=
new
PersonForExternalServiceEvent
(
$service
,
$serviceID
);
$this
->
dispatcher
->
dispatch
(
$event
,
PersonForExternalServiceEvent
::
NAME
);
$person
=
$event
->
getPerson
();
if
(
!
$person
)
{
throw
new
BadRequestHttpException
(
"Unknown service:
$service
"
);
}
return
$person
;
}
private
function
getUserSession
():
UserSessionInterface
private
function
getUserSession
():
UserSessionInterface
{
{
return
$this
->
locator
->
get
(
UserSessionInterface
::
class
);
return
$this
->
locator
->
get
(
UserSessionInterface
::
class
);
...
...
This diff is collapsed.
Click to expand it.
src/Service/LDAPPersonProvider.php
+
0
−
5
View file @
ae233e20
...
@@ -26,11 +26,6 @@ class LDAPPersonProvider implements PersonProviderInterface
...
@@ -26,11 +26,6 @@ class LDAPPersonProvider implements PersonProviderInterface
return
$this
->
ldapApi
->
getPerson
(
$id
);
return
$this
->
ldapApi
->
getPerson
(
$id
);
}
}
public
function
getPersonForExternalService
(
string
$service
,
string
$serviceID
):
Person
{
return
$this
->
ldapApi
->
getPersonForExternalService
(
$service
,
$serviceID
);
}
public
function
getCurrentPerson
():
?Person
public
function
getCurrentPerson
():
?Person
{
{
return
$this
->
ldapApi
->
getCurrentPerson
();
return
$this
->
ldapApi
->
getCurrentPerson
();
...
...
This diff is collapsed.
Click to expand it.
tests/PersonTest.php
+
0
−
11
View file @
ae233e20
...
@@ -121,17 +121,6 @@ class PersonTest extends ApiTestCase
...
@@ -121,17 +121,6 @@ class PersonTest extends ApiTestCase
$this
->
assertEquals
(
$person
->
getExtraData
(
'test'
),
'my-test-string'
);
$this
->
assertEquals
(
$person
->
getExtraData
(
'test'
),
'my-test-string'
);
}
}
public
function
testPersonForExternalServiceEvent
()
{
$user
=
new
AdldapUser
([
'cn'
=>
[
'foobar'
],
],
$this
->
newBuilder
());
$person
=
$this
->
api
->
getPersonForExternalService
(
'test-service'
,
'17'
);
$this
->
assertEquals
(
$person
->
getExtraData
(
'test-service'
),
'my-test-service-string-17'
);
}
// public function testPersonUserItemEvent()
// public function testPersonUserItemEvent()
// {
// {
// $user = $this->api->getPersonUserItem('foobar');
// $user = $this->api->getPersonUserItem('foobar');
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment