10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
tenduke::oidc::osbrowser::OIDCLoginWithLoopbackRedirection Class Reference

#include <OIDCLoginWithLoopbackRedirection.h>

Detailed Description

An implementation of tenduke::sso::OIDCLogin using external browser (the OS default browser) and with "Loopback Interface Redirection" (see https://www.rfc-editor.org/rfc/rfc8252#section-7.3).

In terms of user-experience, this flow is quite obtrusive, but is relatively easy to implement in platform-independent manner. It also has the benefit of not including embedded browser, which might increase the footprint of application noticeably (and embedded browsers are not recommended nowadays, for several reasons).

This flow first starts lightweight local HTTP-server. Then the default OS browser is opened with the URL to start the login. Once the execute succeeds (or fails), the backend sends "redirect"-response to the browser. In this case, the redirect points to an HTTP URL on the loopback interface, e.g. "http://127.0.0.1:9999/callback". The browser receives the redirect response and navigates to the URL. The local HTTP server is listening this URL and then notifies the application of the success (or failure). Finally the HTTP-server is shutdown.

The local HTTP server listens on the IPv4 loopback address only. The redirect URI must therefore be http://127.0.0.1/<path> (recommended, see https://www.rfc-editor.org/rfc/rfc8252#section-8.3) or http://localhost/<path>. The port of the redirect URI is replaced with the port of the server. Prefer 127.0.0.1: with localhost, the browser may first try the IPv6 loopback address (::1), where another local process could be listening on the same port. IPv6 redirect URIs (e.g. http://[::1]/<path>) are not supported. The redirect URI is also configured in the OAuth/OIDC backend, and the two must match.

Inheritance diagram for tenduke::oidc::osbrowser::OIDCLoginWithLoopbackRedirection:
tenduke::oidc::OIDCLogin

Public Member Functions

 OIDCLoginWithLoopbackRedirection (const ::tenduke::oauth::OAuthConfiguration &oauthConfiguration, const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > &oidcConfiguration, std::string scope, const std::shared_ptr< const ::tenduke::oidc::OIDCClientFactory > &oidcClientFactory, const std::shared_ptr< const ::tenduke::osa::BrowserIntegration > &browser, const std::shared_ptr< const ::tenduke::osa::SocketFactory > &socketFactory, std::string responseMessage, std::uint16_t httpServerPort, const std::shared_ptr< const ::tenduke::net::URLs > &urls, const std::shared_ptr< const ::tenduke::http::server::HTTPRequestParser > &httpRequestParser, const std::map< std::string, std::string > &additionalParameters={})
 Constructs a new instance.
std::unique_ptr< tenduke::oidc::OIDCLoginRequest > login () const override
 Starts the login process by creating a login request.

Constructor & Destructor Documentation

◆ OIDCLoginWithLoopbackRedirection()

tenduke::oidc::osbrowser::OIDCLoginWithLoopbackRedirection::OIDCLoginWithLoopbackRedirection ( const ::tenduke::oauth::OAuthConfiguration & oauthConfiguration,
const std::shared_ptr< const ::tenduke::oidc::OIDCConfiguration > & oidcConfiguration,
std::string scope,
const std::shared_ptr< const ::tenduke::oidc::OIDCClientFactory > & oidcClientFactory,
const std::shared_ptr< const ::tenduke::osa::BrowserIntegration > & browser,
const std::shared_ptr< const ::tenduke::osa::SocketFactory > & socketFactory,
std::string responseMessage,
std::uint16_t httpServerPort,
const std::shared_ptr< const ::tenduke::net::URLs > & urls,
const std::shared_ptr< const ::tenduke::http::server::HTTPRequestParser > & httpRequestParser,
const std::map< std::string, std::string > & additionalParameters = {} )

Constructs a new instance.

Parameters
oauthConfigurationOAuth configuration. The redirect URI must be http://127.0.0.1/<path> (recommended) or http://localhost/<path>, see the class description.
oidcConfigurationOIDC configuration
scopeOAuth scope
oidcClientFactoryfactory for creating OIDC clients
browserbrowser integration
socketFactoryfactory for creating sockets
responseMessagemessage to send back to browser, after the login has succeeded. If the login fails, the browser gets a plain "Login failed" page.
httpServerPortport to listen on for the redirect. Use tenduke::osa::RANDOM_AVAILABLE_PORT for a random available port
urlsURL service
httpRequestParserfor parsing http requests
additionalParametersadditional parameters for the request
Exceptions
tenduke::oidc::OIDCExceptionwith error "invalid_redirect_uri" if the redirect URI is not supported

Member Function Documentation

◆ login()

std::unique_ptr<::OIDCLoginRequest > tenduke::oidc::osbrowser::OIDCLoginWithLoopbackRedirection::login ( ) const
overridevirtual

Starts the login process by creating a login request.

Execute the login request to perform the login.

You can keep the login request to e.g. abort a long-running login.

Returns
login request.

Implements tenduke::oidc::OIDCLogin.


The documentation for this class was generated from the following files: