1 // This may look like C code, but it's really -*- C++ -*- 2 /* 3 * Copyright (C) 2017 Emweb bv, Herent, Belgium. 4 * 5 * See the LICENSE file for terms of use. 6 */ 7 #ifndef GOOGLE_SERVICE_H_ 8 #define GOOGLE_SERVICE_H_ 9 10 #include <Wt/Auth/OidcService.h> 11 12 namespace Wt { 13 namespace Auth { 14 15 /*! \brief %OAuth service for Google as third-party authenticator. 16 * 17 * The configuration of the service is done using properties, whose 18 * values need to match the values configured at Google. 19 * 20 * - <tt>google-oauth2-redirect-endpoint</tt>: the URL of the local 21 * redirect endpoint, to which the google OAuth service redirects the user 22 * after authentication. See also redirectEndpoint() 23 * - <tt>google-oauth2-redirect-endpoint-path</tt>: optionally, the deployment 24 * path that corresponds to the redirect endpoint. See also 25 * redirectEndpointPath() 26 * - <tt>google-oauth2-client-id</tt>: The client ID 27 * - <tt>google-oauth2-client-secret</tt>: The client secret. 28 * 29 * For example: 30 * \code 31 * <properties> 32 * <property name="google-oauth2-redirect-endpoint"> 33 * http://localhost:8080/oauth2callback 34 * </property> 35 * <property name="google-oauth2-client-id"> 36 * 123456789012.apps.googleusercontent.com 37 * </property> 38 * <property name="google-oauth2-client-secret"> 39 * abcdefghijk-12312312312 40 * </property> 41 * </properties> 42 * \endcode 43 * 44 * Like all <b>service classes</b>, this class holds only 45 * configuration state. Thus, once configured, it can be safely shared 46 * between multiple sessions since its state (the configuration) is 47 * read-only. 48 * \if cpp 49 * A "const GoogleService" object is thus thread-safe. 50 * \endif 51 * 52 * \if cpp 53 * \sa https://developers.google.com/identity/protocols/OAuth2 54 * \sa https://developers.google.com/identity/protocols/OpenIDConnect 55 * \elseif java 56 * See also: https://developers.google.com/identity/protocols/OAuth2 57 * https://developers.google.com/identity/protocols/OpenIDConnect 58 * \endif 59 * 60 * \if cpp 61 * \note For FastCGI, see also additional configuration in OAuthService 62 * \endif 63 * 64 * \ingroup auth 65 */ 66 class WT_API GoogleService : public OidcService 67 { 68 public: 69 /*! \brief Constructor. 70 */ 71 GoogleService(const AuthService& baseAuth); 72 73 /*! \brief Checks whether a GoogleAuth service is properly configured. 74 * 75 * This returns \c true if a value is found for the three 76 * configuration properties. 77 */ 78 static bool configured(); 79 80 virtual std::string redirectEndpointPath() const override; 81 }; 82 83 } 84 } 85 86 #endif // GOOGLE_SERVICE_H_ 87