Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Encrypting the usernameEncrypting the username
Previous
 
Next
New Post
9/25/2008 9:55 AM
 

We have a client who uses SSN as their username (we have told them how bad of an idea this is).   We need to mask their SSN and then encrypt it in the DB.

We decided to create a custom membership provider, but use the DNN membership provider as a template. 

We have modified the aspnet SP to encrypt the username when creating the user.  It isn't authenticating properly on login because the DB username is encrypted and the passed in username isn't.  We couldn't find a SP that was used for login?  How does this work?  For login we were hoping to find a SP where we could encrypt the incoming username and compare to what was in the DB.

Thanks for your time.

Chad

 

 
New Post
9/25/2008 10:39 AM
 

Hi Chad,

You may be making this more difficult than is necessary.  Why not derive a custom membership provider from the existing AspNetMembershipProvider and override the functions that handle usernames.  These overrides would encrypt incoming usernames (and then pass to base) and decrypt outgoing usernames (after retreival from base).  No need to touch DNN membership or SPs at all.

Unencrypted usernames in this case would be stored in memory unencrypted (and be displayed unencrypted on admin user lists/details), but since DB encryption seems to be the goal, I don't particularly see that as a major drawback.  Probably need to ensure HTTPS for all admin user functions (which is the 4.9 default anyway).

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
9/25/2008 1:57 PM
 

Brandon,

Thank you for your reply.  I think what you are trying to say is encrypt it before going into the DB?  Either way works for us.

I have been looking all over the web for something similiar to what you have suggested.  I understand the concept but I just need a start in the right direction.

The entire site will be https, so that isn't an issue.

Thanks again for your help.

Chad

 
New Post
9/25/2008 6:55 PM
 

Brandon,

I found a good article located here.  http://www.engagesoftware.com/Blog/entryid/41.aspx

I think that is what you are talking about.

Thanks

Chad

 
New Post
9/26/2008 9:05 AM
 

Hi Chad,

Looks like that's the basic idea.  The general pattern will read something like:

Public Class MyMembershipProvider : SqlMembershipProvider

Public Overrides Sub UpdateUser(ByVal user As MembershipUser)

user.Username = EncryptUserName(user.Username)

MyBase.UpdateUser(user)

End Sub

Public Overrides Function GetUser(ByVal providerUserKey As Object, ByVal userIsOnline As Boolean) As MembershipUser

Dim user As MembershipUser = MyBase.GetUser(providerUserKey, userIsOnline)

user.UserName = DecryptUserName(user.UserName)

Return user

End Function

... the rest of the functions that deal with MembershipUsers or UserNames ...

Private Function EncryptUserName(ByVal username As String) As String

...

End Function

Private Function DecryptUserName(ByVal encryptedUsername As String) As String ...

End Class

 

Deploy this class as a compiled assembly to your bin directory, update your web.config, and you should be more or less ready to go.

Note that there is probably a better implementation that utilizes decoration to accept and return decorated (and undecorated) MembershipUsers, but since that is a bit more complex to implement I went with the straightforward method.

You also could probably gain some additional security by hooking into the EncryptPassword and DecryptPassword implementations for your username encryption/decryption.  Doing so would require conversion to and from byte arrays, but you would gain the already solid encryption implementation.

Hope this helps!

Brandon


Brandon Haynes
BrandonHaynes.org
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Encrypting the usernameEncrypting the username


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out