Library: OSP/Shell
Package: Shell
Header: Poco/OSP/Shell/Session.h
The Session class provides user authentication and authorization for the CommandProcessor.
It is also passed as the first argument to the execute() member function of Command, so that command implementations can perform custom authorization.
Member Functions: authService, authenticated, authorize, login, user
Session(
Poco::OSP::BundleContext::Ptr pContext,
const std::string & authServiceName
);
Creates the Session, using the given bundle context and the given service name of the authentication service.
An empty service name disables authentication and authorization.
~Session();
Destroys the Session.
bool authenticated() const;
Returns true if the user is authenticated.
bool authorize(
const std::string & permission
) const;
Returns true if the user is authenticated and has the given permission, false otherwise.
bool login(
const std::string & userName,
const std::string & credentials
);
Attempts to authenticate the user by checking the given userName and credentials with the authentication service.
Returns true if the user was successfully authenticated, false otherwise.
const std::string & user() const;
Returns the name of the current user, or an empty string if no user is logged in.
Poco::OSP::Auth::AuthService::Ptr authService() const;