/usr/include/Wt/Auth/AuthModel is in libwt-dev 3.3.3+dfsg-4.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2011 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WT_AUTH_AUTH_MODEL_H_
#define WT_AUTH_AUTH_MODEL_H_
#include <Wt/Auth/AuthService>
#include <Wt/Auth/FormBaseModel>
#include <Wt/Auth/Identity>
#include <Wt/Auth/User>
namespace Wt {
namespace Auth {
class AbstractPasswordService;
class AbstractUserDatabase;
class Login;
class OAuthService;
/*! \class AuthModel Wt/Auth/AuthModel
* \brief Model for implementing an authentication view.
*
* This model implements the logic for authenticating a user (the
* "login" interface). It implements traditional username/password
* registration, and third party identification methods (although for
* the latter, it doesn't really do anything).
*
* The model exposes three fields:
* - LoginNameField: the login name (used as an identity for the
* Identity::LoginName provider)
* - PasswordField: the password
* - RememberMeField: whether the login should be remembered with an
* authentication cookie (if that is configured in the AuthService).
*
* When the model validates correctly (validate() returns \c true),
* the entered credentials are correct. At that point you can use the
* login() utility function to login the identified user.
*
* The model can also be used when the user is already known (e.g. to
* implement password confirmation before a critical operation). In that
* case you can set a value for the LoginNameField and make this field
* invisible or read-only.
*
* The model also provides the client-side JavaScript logic to
* indicate password attempt throttling (configureThrottling() and
* updateThrottling()).
*
* \sa AuthWidget
*
* \ingroup auth
*/
class WT_API AuthModel : public FormBaseModel
{
public:
//! \brief Password field
static const Field PasswordField;
//! \brief Remember-me field
static const Field RememberMeField;
/*! \brief Constructor.
*
* Creates a new authentication model, using a basic authentication
* service and user database.
*/
AuthModel(const AuthService& baseAuth, AbstractUserDatabase& users,
WObject *parent = 0);
virtual void reset();
virtual bool isVisible(Field field) const;
virtual bool validateField(Field field);
virtual bool validate();
/*! \brief Initializes client-side login throttling.
*
* If login attempt throttling is enabled, then this may also be
* indicated client-side using JavaScript by disabling the login
* button and showing a count-down indicator. This method
* initializes this JavaScript utlity function for a login button.
*
* \sa updateThrottling()
*/
virtual void configureThrottling(WInteractWidget *button);
/*! \brief Updates client-side login throttling.
*
* This should be called after a call to attemptPasswordLogin(), if
* you want to reflect throttling using a client-side count-down
* indicator in the button.
*
* You need to call configureThrottling() before you can do this.
*/
virtual void updateThrottling(WInteractWidget *button);
/*! \brief Logs the user in.
*
* Logs in the user after a successful call to validate(). To avoid
* mishaps, you should call this method immediately after a call to
* validate().
*
* Returns whether the user could be logged in.
*/
virtual bool login(Login& login);
/*! \brief Logs the user out.
*
* This also removes the remember-me cookie for the user.
*/
virtual void logout(Login& login);
/*! \brief Processes an email token.
*
* This simply calls AuthService::processEmailToken().
*/
virtual EmailTokenResult processEmailToken(const std::string& token);
/*! \brief Detects and processes an authentication token.
*
* This returns a user that was identified with an authentication token
* found in the application environment, or an invalid \link User\endlink
* object if this feature is not configured, or no valid cookie was found.
*
* \sa AuthService::processAuthToken()
*/
virtual User processAuthToken();
private:
int throttlingDelay_;
};
}
}
#endif // WT_AUTH_AUTH_MODEL_H_
|