Project

General

Profile

Auth with Unix native users

Added by Niko Sommer over 9 years ago

Hi,

has anybody an idea how to implement login with native Unix user, password?

I thought it would look something like this:

  • Derive own class from Auth::AbstractUserDatabase
  • Replace UserDatabase dbo class in hangman example
  • Reimplement some methods like identity etc. with access over Unix pam API.
  • done

I'm failed at the second step... :((((

I have written my own UserDatabase class derived from Auth::AbstractUserDatabase and configured my webpage so as in the hangman example but without dbo things. All methods return invalid user object for test purposes.

Wt-Application was crashed after click on login button. Crash happens in method Wt::Auth::AuthModel::validate()

crashlog:

0   Wt::Auth::AuthModel::validate       161 0x7ffff7687050  
1   Wt::Auth::AuthWidget::attemptPasswordLogin      438 0x7ffff768ee11  
2   operator()  function_template.hpp   767 0x7ffff767c899  
3   operator()<boost::signals::detail::connection_slot_pair>    signal_template.hpp 119 0x7ffff767c899  
4   dereference slot_call_iterator.hpp  61  0x7ffff767c899  
5   dereference<boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1<void>::caller<Wt::WMouseEvent, boost::function1<void, Wt::WMouseEvent> >, boost::signals::detail::named_slot_map_iterator> > iterator_facade.hpp 514 0x7ffff767c899  
6   operator*   iterator_facade.hpp 639 0x7ffff767c899  
7   postfix_increment_proxy iterator_facade.hpp 145 0x7ffff767c899  
8   operator++<boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1<void>::caller<Wt::WMouseEvent, boost::function1<void, Wt::WMouseEvent> >, boost::signals::detail::named_slot_map_iterator>, boost::signals::detail::unusable, boost::single_pass_traversal_tag, const boost::signals::detail::unusable&, long int>    iterator_facade.hpp 728 0x7ffff767c899  
9   operator()<boost::signals::detail::slot_call_iterator<boost::signals::detail::call_bound1<void>::caller<Wt::WMouseEvent, boost::function1<void, Wt::WMouseEvent> >, boost::signals::detail::named_slot_map_iterator> >  last_value.hpp  49  0x7ffff767c899  
10  boost::signal1<void, Wt::WMouseEvent, boost::last_value<void>, int, std::less<int>, boost::function1<void, Wt::WMouseEvent> >::operator()   signal_template.hpp 354 0x7ffff767c899  
11  Wt::EventSignal<Wt::WMouseEvent>::processDynamic        1129    0x7ffff767cac0  
12  Wt::WebSession::processSignal       2583    0x7ffff7745d56  
13  Wt::WebSession::notifySignal        2557    0x7ffff774dd1c  
14  Wt::WebSession::notify      2127    0x7ffff774f666  
15  Wt::WebSession::handleRequest       1486    0x7ffff7749ffa  
16  Wt::WebController::handleRequest        659 0x7ffff773cb00  
17  operator()  mem_fn_template.hpp 165 0x7ffff7bb3eff  
18  operator()<boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list0>   bind.hpp    313 0x7ffff7bb3eff  
19  operator()  bind_template.hpp   20  0x7ffff7bb3eff  
20  asio_handler_invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > >   handler_invoke_hook.hpp 64  0x7ffff7bb3eff  
21  invoke<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > >, boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > >   handler_invoke_helpers.hpp  37  0x7ffff7bb3eff  
22  boost::asio::detail::completion_handler<boost::_bi::bind_t<void, boost::_mfi::mf1<void, Wt::WebController, Wt::WebRequest*>, boost::_bi::list2<boost::_bi::value<Wt::WebController*>, boost::_bi::value<http::server::HTTPRequest*> > > >::do_complete  completion_handler.hpp  68  0x7ffff7bb3eff  
23  complete    task_io_service_operation.hpp   37  0x7ffff7b943be  
24  do_run_one  task_io_service.ipp 384 0x7ffff7b943be  
25  boost::asio::detail::task_io_service::run   task_io_service.ipp 153 0x7ffff7b943be  
26  run io_service.ipp  59  0x7ffff758a33c  
27  Wt::WIOService::run     160 0x7ffff758a33c  
28  ??  /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0     0x7ffff53cca4a  
29  start_thread        312 0x7ffff55df182  
30  clone       111 0x7ffff63b047d  

Can anybody help me?

//Constructor content of WApplication class

   session.login().changed().connect(this, &ProdMon::loginChanged);
   Auth::AuthModel *authModel = new Auth::AuthModel(Session::auth(),
                              session.users(), this);
   authModel->addPasswordAuth(&Session::passwordAuth());

   Auth::AuthWidget *authWidget = new Auth::AuthWidget(session.login());
   authWidget->setModel(authModel);
   root()->addWidget(authWidget);

other sources are in attachement.