Comments (5)
Hello @likou31
Could you show your security settings (yaml) and your User class?
from onelogin-saml-bundle.
Actually I found a solution.
It was the provider's fault.
In the SamlUserProvider in loadUserByIdentifier(), it creates a new userClass everytime.
I created my own UserProvider that extends the SamlUserProvider, and I changed the method like this (I also changed the __construct method to add the repository) :
public function __construct(
protected string $userClass,
protected array $defaultRoles,
protected UserRepository $repository,
ManagerRegistry $doctrine
) {
$this->repository = $doctrine->getManager()->getRepository('App:User');
if (!is_a($userClass, UserInterface::class, true)) {
throw new \InvalidArgumentException('The $userClass argument should be a class implementing the '.UserInterface::class.' interface.');
}
}
public function loadUserByIdentifier(string $identifier): UserInterface
{
$user = $this->repository->loadUserByIdentifier($identifier);
if ($user != null) {
return $user;
} else {
return new $this->userClass($identifier, $this->defaultRoles);
}
}
If it can help anyone, I'll be happy !
from onelogin-saml-bundle.
In the SamlUserProvider in loadUserByIdentifier(), it creates a new userClass everytime.
It's exactly what it created for. If you want to load a user from database, the Entity User Provider might be suitable for you.
Also, I recommend you to read Just-in-time user provisioning section from README.
from onelogin-saml-bundle.
For my needs, I need to load it from the saml server, and persist the user. But not create each time a new user entity. (and I need to do the relation between others entities for example)
from onelogin-saml-bundle.
IIUC Just-in-time user provisioning is what you need. Use of the Saml User Factory is more convenient approach than the custom user provider which instantiates new User. But if it works for you and looks clearer, it's also good. =)
from onelogin-saml-bundle.
Related Issues (20)
- Misleading information about ONELOGIN_CUSTOMPATH HOT 2
- Failed to Load Resources HOT 1
- <request_scheme_and_host> with x-forwarded-prefix
- Deprecation Note in Symfony 6.2 HOT 1
- Is it possible to set returnTo? HOT 2
- Override reply (assertion customer service) doesn't work. HOT 1
- Events not firing (UserCreatedEvent, UserUpdatedEvent) HOT 3
- User provider: load by SAML attributes? HOT 5
- Multiple idP: restrict email by format HOT 4
- Nbgrp_onlelogin_saml.yaml and .env variables HOT 1
- Multiple IDP use without specifying which one to use on idp side HOT 1
- Routes not working after fresh installation HOT 2
- JIT provisioning and persisting User doesn't change anything in the database HOT 4
- ADFS Problem HOT 2
- Symfony 7 support? HOT 8
- Need to use urn:federation:authentication:windows for requestedAuthnContext
- Need to disable onelogin behaviours
- Problem with the settings for Azure HOT 1
- Inject <saml:Subject><saml:NameID> into User-Entity HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onelogin-saml-bundle.