How to authenticate with Entity Framework - entity-framework

I have an Entity Framework model that contains the tables
apsnet_Users
aspnet_Memberships
I want to check for the validation of username, and password in WCF library how to achieve that
Shall I add membership to the app.config, how to achieve something like that?
Best regards

A basic (but secure) username/password database should have columns something like this:
UserName - Text
PasswordSalt - Binary
PasswordHash - Binary
The user name can be stored as plain text.
The salt is a random string of bytes, preferably at least as long as the hash.
The password hash is the binary hash of the password + salt.
Here is the basic procedure when giving a user a new password. I will use SHA-256 hashing as an example.
Convert the desired password into a byte array.
Use a CSPRNG to generate another byte array, 32 bytes long. This is the salt.
Add the salt to the end of the password byte array.
Hash the password with SHA-256.
Store the salt in the database.
Store the password hash in the database.
Then when a user enters their password when logging in, this is the procedure.
Look up the user in the database.
Convert the entered password into a byte array.
Add the salt from the database to the end of the password byte array.
Hash the password with SHA-256.
If the hash matches the hash in the database, the password was correct.
This method of password authentication is the preferred method for high-security applications. It is not slow, nor very hard to implement. The best thing is, you can give the entire password table to anyone you please, and the most they will be able to do is pick a user and start guessing passwords.

I failed to use entity framework, and the other algorithms of authontications, so I used Membership with SQL directly , Microsaoft encrypt bu way so hard to retrieve

Related

Cakephp 2.4 Re-hash stored values in database

I am new to cakephp and I need some help.
I have a database with hashed password of users, and I want to update HASH $key (just for security) so I want to rehash users password with new seed, So they donĀ“t have to set password again.
Any suggestions ?
Thanks in advance

Why is hash function fast?

Let's say I created a database that stores just name and password.
Then if I use a hash function(let's say md5) to one-way encrypt the password which the user enters when signing up.
Name = "James"
Password = "password1234" -> "bdc87b9c894da5168059e00ebffb9077"
The encrypted message will be stored in the database with his name "James"
Now when he enters his password to login, his password's md5 hash will be compared with the encrpyted message in the database.
So, if there is 1 million data on my database, the server will need to search through all the data to find "bdc87b9c894da5168059e00ebffb9077".
How come is it possible to locate the password's position instantly?

Hash method in Laravel

I have a question concerning the Hash::make method in Laravel 4.2 .. I've notice that it returns always a different string for the same value . So I am wondering if this affects If I want to look for a user using his email and hashed password in the table . If it's not ? Why I have then this issue of not getting a user with correct credentials from the table using the where statements (where email and where password) ? but when I look for it using just the email it works .. I am 100% convinced it's just about the Password . What do you think ?
You get different hashes on purpose, the function adds a random salt to each hashed password. This is important to get secure hashes.
// Hash a new password for storing in the database.
// The function automatically generates a cryptographically safe salt.
$hashToStoreInDb = Hash::make($password);
The verification cannot be done in the SQL statement directly, instead you can search for the user by username/email, get the stored password-hash, and afterwards verify the entered password with the password-hash from the database.
// Check if the hash of the entered login password, matches the stored hash.
// The salt and the cost factor will be extracted from $existingHashFromDb.
$isPasswordCorrect = Hash::check($password, $existingHashFromDb);

Difference between setIdentity and setCredential in Zend Framework

What is the difference between setIdentity and setCredential in Zend Framework?
$authAdapter->setIdentityColumn('username')
->setCredentialColumn('password');
$authAdapter->setIdentity($data['username'])
->setCredential($data['password']);
Please help me I need some detailed explanation.
identityColumn: This is the name of the database table column used to represent the identity. The identity column must contain unique values, such as a username or e-mail address.
credentialColumn: This is the name of the database table column used to represent the credential. Under a simple identity and password authentication scheme, the credential value corresponds to the password. See also the credentialTreatment option.
Basically, setIdentity tells the system to set a username and setCredential tells the system to set the provided password for authentication.
Hope it helps.
Ref: Zend Table

SugarCRM user password

I've created a user in SugarCRM; once I've created a user the password is mailed to the user.
I see the table user, but the user_hash is blank.
Where does it store the password before it sends an email?
Check the column 'system_generated_password'. 'user_hash' will be null until the new user logs in with the the system generated password and then creates a new password for themselves.
I think you might be mistaken. I just created a new user with a user name new_user. I then did the following query:
SELECT * FROM users WHERE user_name = "new_user"
The user_hash has a value of 1e3fab09c625a96334d18d2da27dae46.
I double-checked, and the password emailed to me was l7YaR7, which md5 hashes to the above.
I did this in Sugar 6.1.1. What version are you using?
Also, did the email get sent out? It's possible that the password hash isn't sent to the DB until after the email has been successfully sent.
You can create user using md5 function if you using phpmyadmin.
You can alter the passworld and use md5() function;