Wt  3.2.1
Classes | Public Member Functions | Protected Member Functions
Wt::Auth::OAuthProcess Class Reference

An OAuth authorization (and authentication) process. More...

#include <Auth/OAuthService>

Inheritance diagram for Wt::Auth::OAuthProcess:
Inheritance graph
[legend]

List of all members.

Classes

class  TokenError
 Exception thrown while parsing a token response. More...

Public Member Functions

const std::string & scope () const
 Returns the scope for which this process was created.
const OAuthServiceservice () const
 Returns the OAuth service which spawned this process.
virtual void startAuthorize ()
 Starts an authorization process.
virtual void startAuthenticate ()
 Starts an authorization and authentication process.
virtual void getIdentity (const OAuthAccessToken &token)
 Obtains an authenticated identity.
WString error () const
 Error information, in case authentication or identification failed.
const OAuthAccessTokentoken () const
 Returns the access token.
Signal< OAuthAccessToken > & authorized ()
 Authorization signal.
Signal< Identity > & authenticated ()
 Authentication signal.

Protected Member Functions

 OAuthProcess (const OAuthService &service, const std::string &scope)
 Constructor.
virtual OAuthAccessToken parseTokenResponse (const Http::Message &response)
 Parses the response for a token request.
virtual void setError (const WString &e)
 Sets the error.

Detailed Description

An OAuth authorization (and authentication) process.

The process implements the state machine that is needed to complete an OAuth authorization cycle.

Optionally, it also provides authentication, by using the service-specific logic which uses the access token to return identity information.

A process is created for a particular scope, which represents what kind of information one wants to access, and which is used to inform the user of the kind of operations he needs to authorize for your application to make with his protected data.

See also:
OAuthService::createProcess()

Constructor & Destructor Documentation

Wt::Auth::OAuthProcess::OAuthProcess ( const OAuthService service,
const std::string &  scope 
) [protected]

Constructor.

See also:
OAuthService::createProcess()

Member Function Documentation

Signal<Identity>& Wt::Auth::OAuthProcess::authenticated ( )

Authentication signal.

This signal indicates the end of an authentication process started with startAuthenticate() or getIdentity(). If the authentication process was successful, then the parameter is a valid and authentic identity. If the authentication process failed then the identity parameter is invalid, and you can get more information using error().

Authentication can fail because authorization failed (in case of startAuthenticate()), or because of a protocol error, or configuration problem.

See also:
startAuthenticate(), getIdentity(), Identity::isValid()
Signal<OAuthAccessToken>& Wt::Auth::OAuthProcess::authorized ( )

Authorization signal.

This signal indicates the end of an authorization process started with startAuthorize(). If the authorization process was successful, then the parameter carries a valid access token that was obtained. If the authorization process failed then the access token parameter is invalid, and you can get more information using error().

Authorization can fail because of a protocol error, aconfiguration problem, or because the user denied the authorization.

See also:
startAuthorize(), OAuthAccessToken::isValid()
WString Wt::Auth::OAuthProcess::error ( ) const

Error information, in case authentication or identification failed.

The error message contains details when the authorized() or authenticated() signals indicate respectively an invalid token or invalid identity.

void Wt::Auth::OAuthProcess::getIdentity ( const OAuthAccessToken token) [virtual]

Obtains an authenticated identity.

The authentication process uses an access token to issue one or more protected requests for obtaining identity information. This is not part of the OAuth protocol, since OAuth does not standardize the use of the access token to obtain this information.

The authentication process ends with the authenticated() signal which signals the obtained identity.

OAuthAccessToken Wt::Auth::OAuthProcess::parseTokenResponse ( const Http::Message response) [protected, virtual]

Parses the response for a token request.

Throws a TokenError when the response indicates an error, or when the response could not be properly parsed.

Some OAuth implementations may uses a non-standard encoding of the token.

const std::string& Wt::Auth::OAuthProcess::scope ( ) const

Returns the scope for which this process was created.

The scope represents how much protected information the web application wants to access, and in what way.

See also:
OAuthService::createProcess(), OAuthService::authenticationScope()
const OAuthService& Wt::Auth::OAuthProcess::service ( ) const

Returns the OAuth service which spawned this process.

See also:
OAuthService::createProcess()
void Wt::Auth::OAuthProcess::setError ( const WString e) [protected, virtual]

Sets the error.

This should be used in getIdentity() implementations to set the error, before emitting authenticated() with an invalid Identity.

void Wt::Auth::OAuthProcess::startAuthenticate ( ) [virtual]

Starts an authorization and authentication process.

This is startAuthorize() followed by getIdentity().

This requires that the process is created with an authorization scope that includes sufficient rights for authentication (at least OAuthService::authenticationScope())

The authentication process ends with the authenticated() signal which signals the obtained identity.

Note:
To be able to use a popup (instead of a page redirect), you should connect this method directly to an, since popup windows are blocked in most web browsers unless they are the direct consequence of an event.
void Wt::Auth::OAuthProcess::startAuthorize ( ) [virtual]

Starts an authorization process.

This starts an authorization process to request an accesstoken to access protected information within the process scope.

The authorization process ends with the authorized() signal which signals the obtained token.

Note:
To be able to use a popup (instead of a page redirect), you should connect this method directly to an, since popup windows are blocked in most web browsers unless they are the direct consequence of an event.
const OAuthAccessToken& Wt::Auth::OAuthProcess::token ( ) const

Returns the access token.

This returns the access token that was obtained in the last authorization cycle.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Mar 30 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1