/    Sign up×
Community /Pin to ProfileBookmark

User Object and Security

Hey all,
I’m programming my first user interface with login and account management using PHP and I’m stuck on this issue. I’m just about to finish creating my method in creating new user accounts when a thought hit me about my design.

Here’s what happens. When the user attempts to log in, the program takes the string (haven’t filtered it yet) and checks to see if the user name and password provided is within the database using the user class I created. If the user is found in the database, the username is encrypted using an algorithm from another class, their credential levels are returned, and both values are stored with the user object on a $_SESSION variable. Another session variable is also created that mimics the value of the credential level stored within the object. Should either be unequal to each other, then the session was tampered.

Now on the user class definition (method list), there are methods that allow for the decode and encoding of the encrypted username; wich brings me to my question. Considering the user object is defined by this class which holds these methods to decode and encode the username, would this be considered a security risk? This class will be the same one used for logging in general users, too so I’m not sure…

To clarify, the password is stored as a md5 hash on the DB already. Maybe I am thinking about objects the wrong way, but within my created user object, I am able to do something like this:
Since Username is stored in user object and user name is encrypted,

$_SESSION[‘DAUSER’] = new user(username,password,blah,blah); $_SESSION[‘DAUSER’]->doLogin();
$realuser = $_SESSION[‘DAUSER’]->getDecryptUserName()

My question is at getDecryptUserName() if having the method in the same class that is being used to create the user object is a security risk.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @XTREEMMAK spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...