Le 8/7/13 4:11 PM, Hunter McMillen a écrit :
> What are the common ways to authenticate users using Mina?
>
> The first attempt I made was using a state machine, but I had problems
> integrating that with an IoHandler.
>
> In retrospect, the state machine seems like overkill; so I was hoping
> to get ideas for other ways to authenticate users, or maybe a link to
> an application that does some authentication.
>
> would it be terrible to do something like this?
>
> public void sessionCreated(IoSession session) {
>     authenticateUser()  // < ----- Good idea? Bad Idea? Run in a
> separate thread?
> }

Depends...

let's see how it works with LDAP :

- the user can connect on the server (and the sessionCreated event is
handled), but the user will not be authentified at this point.

- in order to authenticate the user, we need to know about the user.
Just having his IP address is certainly not good enough (it's easy to
spoof it), so we expect the client to sent some credentials in the first
dedicated message. In LDAP this is done through a BindRequest. Anyway,
as you require the user to send you some data, you have to process them
by handling the messageReceived event.


Last, not least : what about a separate thread ?

That's a good question. The answer, again is "it depends". If it takes
seconds to authenticat a user, because you have to send the auth request
to a remote server, then having a separate thread for that sounds smart.
Most of the time, the authent will take a few ms, and will be done quite
rarely, so it's enough to execute this code in the same thread.

Hope it helps.

-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com 

Reply via email to