ldap avatar
This commit is contained in:
parent
41e11123da
commit
1be43b086c
2
.env
2
.env
|
@ -67,7 +67,7 @@ OAUTH_USERNAME=username
|
||||||
OAUTH_EMAIL=email
|
OAUTH_EMAIL=email
|
||||||
OAUTH_LASTNAME=lastname
|
OAUTH_LASTNAME=lastname
|
||||||
OAUTH_FIRSTNAME=firstname
|
OAUTH_FIRSTNAME=firstname
|
||||||
OAUTH_AVATAR=avatar
|
OAUTH_AVATAR=picture
|
||||||
OAUTH_AUTOSUBMIT=1 # if APP_AUTH = OPENID autocréer les users non existant
|
OAUTH_AUTOSUBMIT=1 # if APP_AUTH = OPENID autocréer les users non existant
|
||||||
OAUTH_AUTOUPDATE=1 # if APP_AUTH = OPENID automodifier les users existant
|
OAUTH_AUTOUPDATE=1 # if APP_AUTH = OPENID automodifier les users existant
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ framework:
|
||||||
# Remove or comment this section to explicitly disable session support.
|
# Remove or comment this section to explicitly disable session support.
|
||||||
session:
|
session:
|
||||||
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
|
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler
|
||||||
|
name: 'nuosso'
|
||||||
save_path: '@Redis'
|
save_path: '@Redis'
|
||||||
gc_probability: null
|
gc_probability: null
|
||||||
cookie_secure: auto
|
cookie_secure: auto
|
||||||
|
|
|
@ -15,5 +15,5 @@
|
||||||
"code"
|
"code"
|
||||||
],
|
],
|
||||||
"logo_uri": "http://127.0.0.1:8080/images/logo.png",
|
"logo_uri": "http://127.0.0.1:8080/images/logo.png",
|
||||||
"scope": "openid"
|
"scope": "openid profile email"
|
||||||
}
|
}
|
|
@ -87,6 +87,7 @@ class HydraController extends AbstractController
|
||||||
'email' => $user->getEmail(),
|
'email' => $user->getEmail(),
|
||||||
'firstname' => $user->getFirstname(),
|
'firstname' => $user->getFirstname(),
|
||||||
'lastname' => $user->getLastname(),
|
'lastname' => $user->getLastname(),
|
||||||
|
'picture' => $user->getAvatar(),
|
||||||
];
|
];
|
||||||
$request->getSession()->set('datas', $datas);
|
$request->getSession()->set('datas', $datas);
|
||||||
|
|
||||||
|
@ -148,7 +149,7 @@ class HydraController extends AbstractController
|
||||||
$email = "$username@nomail.fr";
|
$email = "$username@nomail.fr";
|
||||||
$lastname = $username;
|
$lastname = $username;
|
||||||
$firstname = ' ';
|
$firstname = ' ';
|
||||||
$firstname = 'noavatar.png';
|
$avatar = '';
|
||||||
|
|
||||||
// Rechercher l'utilisateur
|
// Rechercher l'utilisateur
|
||||||
if (isset($userldap[$this->getParameter('ldapFirstname')])) {
|
if (isset($userldap[$this->getParameter('ldapFirstname')])) {
|
||||||
|
@ -164,7 +165,7 @@ class HydraController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($userldap[$this->getParameter('ldapAvatar')])) {
|
if (isset($userldap[$this->getParameter('ldapAvatar')])) {
|
||||||
$avatar = $userldap[$this->getParameter('ldapAvatar')];
|
$avatar = "data:image/jpeg;base64,".base64_encode($userldap[$this->getParameter('ldapAvatar')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->apiservice->run('PUT', $this->getParameter('hydraLoginchallengeaccept').$request->getSession()->get('hydraChallenge'), ['subject' => $email, 'acr' => 'string']);
|
$response = $this->apiservice->run('PUT', $this->getParameter('hydraLoginchallengeaccept').$request->getSession()->get('hydraChallenge'), ['subject' => $email, 'acr' => 'string']);
|
||||||
|
@ -177,6 +178,7 @@ class HydraController extends AbstractController
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'firstname' => $firstname,
|
'firstname' => $firstname,
|
||||||
'lastname' => $lastname,
|
'lastname' => $lastname,
|
||||||
|
'picture' => $avatar,
|
||||||
];
|
];
|
||||||
$request->getSession()->set('datas', $datas);
|
$request->getSession()->set('datas', $datas);
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ class SecurityController extends AbstractController
|
||||||
$email = "$username@nomail.fr";
|
$email = "$username@nomail.fr";
|
||||||
$lastname = $username;
|
$lastname = $username;
|
||||||
$firstname = ' ';
|
$firstname = ' ';
|
||||||
$avatar = 'noavatar.png';
|
$avatar = 'images/noavatar.png';
|
||||||
|
|
||||||
// Rechercher l'utilisateur
|
// Rechercher l'utilisateur
|
||||||
if (isset($attributes[$this->getParameter('casUsername')])) {
|
if (isset($attributes[$this->getParameter('casUsername')])) {
|
||||||
|
@ -170,7 +170,7 @@ class SecurityController extends AbstractController
|
||||||
$email = "$username@nomail.fr";
|
$email = "$username@nomail.fr";
|
||||||
$lastname = $username;
|
$lastname = $username;
|
||||||
$firstname = ' ';
|
$firstname = ' ';
|
||||||
$avatar = 'noavatar.png';
|
$avatar = 'images/noavatar.png';
|
||||||
|
|
||||||
// Rechercher l'utilisateur
|
// Rechercher l'utilisateur
|
||||||
if (isset($userldap[$this->getParameter('ldapFirstname')])) {
|
if (isset($userldap[$this->getParameter('ldapFirstname')])) {
|
||||||
|
@ -212,7 +212,7 @@ class SecurityController extends AbstractController
|
||||||
$state = Uuid::uuid4();
|
$state = Uuid::uuid4();
|
||||||
$request->getSession()->set('oauthState', $state);
|
$request->getSession()->set('oauthState', $state);
|
||||||
$callback = $this->generateUrl('app_loginopenidcallback', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
$callback = $this->generateUrl('app_loginopenidcallback', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||||
$url = $this->getParameter('oauthLoginurl').'?client_id='.$this->getParameter('oauthClientid').'&redirect_uri='.$callback.'&response_type=code&state='.$state.'&scope=openid';
|
$url = $this->getParameter('oauthLoginurl').'?client_id='.$this->getParameter('oauthClientid').'&redirect_uri='.$callback.'&response_type=code&state='.$state.'&scope=openid profile email';
|
||||||
|
|
||||||
return $this->redirect($url);
|
return $this->redirect($url);
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ class SecurityController extends AbstractController
|
||||||
$email = "$username@nomail.fr";
|
$email = "$username@nomail.fr";
|
||||||
$lastname = $username;
|
$lastname = $username;
|
||||||
$firstname = ' ';
|
$firstname = ' ';
|
||||||
$avatar = 'noavatar.png';
|
$avatar = 'images/noavatar.png';
|
||||||
|
|
||||||
// Récupérer les attributs associés
|
// Récupérer les attributs associés
|
||||||
if (isset($attributes[$this->getParameter('oauthEmail')])) {
|
if (isset($attributes[$this->getParameter('oauthEmail')])) {
|
||||||
|
@ -385,7 +385,7 @@ class SecurityController extends AbstractController
|
||||||
$email = $username.'@nomail.com';
|
$email = $username.'@nomail.com';
|
||||||
}
|
}
|
||||||
if (empty($avatar)) {
|
if (empty($avatar)) {
|
||||||
$avatar = 'noavatar.png';
|
$avatar = 'images/noavatar.png';
|
||||||
}
|
}
|
||||||
if (empty($firstname)) {
|
if (empty($firstname)) {
|
||||||
$firstname = ' ';
|
$firstname = ' ';
|
||||||
|
@ -414,7 +414,7 @@ class SecurityController extends AbstractController
|
||||||
|
|
||||||
private function updateuser($user, $firstname, $lastname, $email, $avatar, $em)
|
private function updateuser($user, $firstname, $lastname, $email, $avatar, $em)
|
||||||
{
|
{
|
||||||
if ('noavatar.png' == $avatar) {
|
if ('images/noavatar.png' == $avatar) {
|
||||||
$avatar = $user->getAvatar();
|
$avatar = $user->getAvatar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
|
||||||
private $email;
|
private $email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=250, nullable=true, options={"default" : 0})
|
* @ORM\Column(type="text")
|
||||||
*/
|
*/
|
||||||
private $avatar;
|
private $avatar;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<div class="card mt-5" style="max-width:600px; margin:auto;">
|
<div class="card mt-5" style="max-width:600px; margin:auto;">
|
||||||
<div class="card-body d-flex">
|
<div class="card-body d-flex">
|
||||||
<div>
|
<div>
|
||||||
<img src="{{ asset('images/' ~ app.user.avatar)}}" style="height:100px; background-color: #212529"/>
|
<img src="{{ (app.user.avatar starts with 'images/' ? asset(app.user.avatar) : app.user.avatar ) }}" style="height:100px; background-color: #212529"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ps-3">
|
<div class="ps-3">
|
||||||
|
|
Loading…
Reference in New Issue