using fosUserBundle's authentication in separate program - symfony

I would like to use the hash algorithm from FOSUserBundle in a standalone app.
Here's what I want to do:
-Copy the user table into a standalone app
-Let users use their symfony2 login in my separate app
In order to do this, I need to code a copy of the FOSUserBundles authentication in my app.
So my question is - where can I find this algorithm in the FOSUserBundle codebase? Is it just a md5() together with the user specific salt or how is it constructed?
Thanks!
* UPDATE *
So while this would certainly be interesting to know how to do, I am now faced instead with changing the algorithm in FOSUserBundle, so I will have to do it the other way around. And I will open a different topic for that.

To answer your original question:
Password encoders are part of the Synfony's core, not FOSUserBundle. You may find them in vendor/symfony/symfony/src/Symfony/Component/Security/Core/Encoder.
To find the correct encoder to use in your custom script look what you have configured for FOSUserBundle.

Related

symfony configuration parameter storage entity

In a symfony project, I'm looking the best way to storage some configuration parameter such as the application is online, offline or accesible.
I need to change this value constantly from the web interface with my role ADMIN, so I could put the application offline during maintenance period, but for the ADMIN role the application will be available (not for other users). In each redirect, I ask for this configuration (this is already agreed).
I thougth create an entity with this configuration param, but this table will have no more than one row, so I'm asking me if this is the best way. Is there any other way to storage this param in Symfony?
Thanks a lot.
Having a "settings" table for this sort of things is a common solution. You can manage them easily with SettingsBundle.
Alternatively you could use Symfony Cache to store it: https://stackoverflow.com/a/43785356/1637446

Connecting data two ways ASP.NET Core MVC

I'm quite new to development and I have recently gotten into ASP.NET Core and I need help to figure out the following:
I need to connect my "characters" to my users upon creation via linking the username to the certain character, how would I go about to do this?
My guess is that upon the create method POST in my "CharactersController" I should be able to edit the "UserName" column for the characters upon creation to be linked to the user currently creating the character. But I am unsure how to do this.
I have tried to find relevant information in the documentation and in different guides but nothing seems to be what I'm looking for.
I appreciate any answers, thank you!
If you've already setup authentication / authorization properly, you should be able to use the method
User.FindFirst(ClaimTypes.NameIdentifier).Value
provided by the HttpContextAccessor library.

Password Reset Email

Within a Symfony2 application I'm building I've managed to get user account creation, login, updating profile working using bootstrap for the frontend and 'out of the box' Symfony2 for the rest. I need to add the ability for users to reset their passwords and/or have email sent with a generated password. I'll preface these questions with the fact I am new to developing in Symfony2. My questions are 1) Do I try and use FOSUserBundle in parallel with code I have already written or 2) Are there ways to implement this without FOSUserBundle. These are questions are really coming from a place of not knowing any better.
Thank you in advance.
I'm not a symfony guy but I only know that Symfony embraces the "don't reinvent the wheel" philosophy. Symfony itself is a collection of bundles. If this is your first time with a web framework I can tell that you've passed a lot of time and effort implementing something that other developers offered to you. Believe me if you want to build something powerful and standardized FOSuserbundle will undoubtedly satisfy your need.
Always sad to see a genuinely asked question downvoted.
#Brent was a Symfony novice myself and in many ways probably still am. I wouldn't say Symfony embraces "don't reinvent the wheel" but rather "speed up app development". I am sure you can take days searching Stackoverflow and find possible (probably a little bit outdated) solutions to your problem or do as #AzizFCB suggested and use a ready Symfony bundle, in fact, the most widely used and adopted Symfony bundle. Unless your app's core activity is solving people's login and forgot password problems. I would strongly advise to use FOSUserBundle, solve that problem in a few hours importantly including updates (especially security) that you don't need to manage (but if you can please contribute to) and focus your efforts on coding your apps core activity(s).

Symfony2 FOSUserBundle Role entities

I'm currently trying to figure out the best way to implement doctrine persisted Role entities as a M2M relationship compatible with FOSUserBundle. Previously I was using just strings with the default implementation and was persisting it with a doctrine array mapping.
Now I need to have roles as seperate entites as we want to build an admin backend where others can grant users roles.
Basically, it's a pain in the ass. The FOS interfaces are built for string representations, not Role entities. Change the implementation, you break a lot of stuff i.e. FOS commands to promote users. And it's hard to figure out exactly which pieces of the interfaces are needed to allow the symfony2 security system to continue working correctly.
I could rewrite the role management code and use Role entities as much as possible, e.g.:
$user->addRole(new Role('ROLE_FOO'));
But that breaks commands and possibly existing code?
Or continue using:
$user->addRole('ROLE_FOO');
And couple role/entity manager code in addRole() (bad design).
I've noticed this is a grey area (Role entities with FOS) and has been mentioned on the symfony2 boards and round here, but no decent solutions.
Anyone had any experience or can think of a decent solution?
I decided to go with a mix of an array/ArrayCollection implementation. I tried to follow the existing interfaces as much as possible so as not to break the security system. I have documented my solution at http://blog.jmoz.co.uk/symfony2-fosuserbundle-role-entities

How to use ASP.NET membership provider for pre-exists data

I already got a table stored all customer information. Such as name, email phone, password and other things.
In this case, how can I take advantages of asp.net membership/role/profile provider?
I want to use annotation in MVC2 to do authentication and such.
Thanks for your advice, any reading URL is welcome.
You'll probably need to create custom membership provider.
Check out:
MSDN Article
ASP.Net Video
And see if they help you
There are very simple way
1. use aspnet_regsql.exe
(in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727)
Choose option add to existing database
Use your name, email, phone like Profile, or you can create script which add users automatically(and you need add to this user phone,email etc)
http://forums.asp.net/p/1540444/3753784.aspx
(It's useful documentation about asp.net roles,membership etc)
https://web.archive.org/web/20211020202857/http://www.4guysfromrolla.com/articles/120705-1.aspx
I'm throwing in a CW answer to compare/contrast the other two "real" answers.
So you have two choices: Use the standard membership provider and their database schema as per John's answer, or create your own membership provider and utilize your current database as per user517656's answer.
If you use the standard provider, you'll have to migrate your users into the microsoft database. But once you do that, you shouldn't have to write much code at all.
If you use a custom provider you have to write all of the code yourself, but you don't have to change your database.

Resources