-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documentation improvements, oauth feature example
- Loading branch information
Koen Deforche
committed
Feb 22, 2012
1 parent
c6e7505
commit 991043c
Showing
33 changed files
with
320 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ SUBDIRS( | |
mediaplayer | ||
miniwebgl | ||
multiple_servers | ||
oauth | ||
serverpush | ||
socketnotifier | ||
suggestionpopup | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<server> | ||
<application-settings location="*"> | ||
<properties> | ||
|
||
<!-- You need to register at google for this to work, and enter | ||
there the same values as you do here. --> | ||
<!-- | ||
<property name="google-oauth2-redirect-endpoint"> | ||
http://localhost:8080/oauth2callback | ||
</property> | ||
<property name="google-oauth2-client-id"> | ||
00000000000.apps.googleusercontent.com | ||
</property> | ||
<property name="google-oauth2-client-secret"> | ||
abcdefghijk-123456789xyz | ||
</property> | ||
--> | ||
</properties> | ||
</application-settings> | ||
</server> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
WT_ADD_EXAMPLE(oauth.wt | ||
OAuth.C | ||
) | ||
|
||
TARGET_LINK_LIBRARIES(auth.wt) | ||
|
||
INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2012 Emweb bvba, Kessel-Lo, Belgium. | ||
* | ||
* See the LICENSE file for terms of use. | ||
*/ | ||
#include <Wt/WApplication> | ||
#include <Wt/WContainerWidget> | ||
#include <Wt/WImage> | ||
#include <Wt/WServer> | ||
#include <Wt/WText> | ||
|
||
#include <Wt/Auth/AuthService> | ||
#include <Wt/Auth/GoogleService> | ||
|
||
Wt::Auth::AuthService authService; | ||
Wt::Auth::GoogleService *googleService = 0; | ||
|
||
class OAuthApplication : public Wt::WApplication | ||
{ | ||
public: | ||
OAuthApplication(const Wt::WEnvironment& env) | ||
: Wt::WApplication(env) | ||
{ | ||
if (!googleService) { | ||
new Wt::WText("This example requires a Google Auth service " | ||
"configuration", root()); | ||
return; | ||
} | ||
|
||
process_ = googleService->createProcess | ||
(googleService->authenticationScope()); | ||
Wt::WImage *ggi = new Wt::WImage("css/oauth-google.png", root()); | ||
ggi->clicked().connect(process_, | ||
&Wt::Auth::OAuthProcess::startAuthenticate); | ||
|
||
process_->authenticated().connect(this, &OAuthApplication::authenticated); | ||
} | ||
|
||
void authenticated(const Wt::Auth::Identity& identity) { | ||
root()->clear(); | ||
new Wt::WText("Welcome, " + identity.name(), root()); | ||
} | ||
|
||
private: | ||
Wt::Auth::OAuthProcess* process_; | ||
}; | ||
|
||
Wt::WApplication *createApplication(const Wt::WEnvironment& env) | ||
{ | ||
return new OAuthApplication(env); | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
try { | ||
Wt::WServer server(argv[0]); | ||
|
||
server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION); | ||
server.addEntryPoint(Wt::Application, createApplication); | ||
|
||
if (Wt::Auth::GoogleService::configured()) { | ||
googleService = new Wt::Auth::GoogleService(authService); | ||
} | ||
|
||
if (server.start()) { | ||
Wt::WServer::waitForShutdown(); | ||
server.stop(); | ||
} | ||
} catch (Wt::WServer::Exception& e) { | ||
std::cerr << e.what() << std::endl; | ||
} catch (std::exception &e) { | ||
std::cerr << "exception: " << e.what() << std::endl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Auth1 feature example | ||
--------------------- | ||
|
||
This is an example that illustrates the use of the | ||
`Wt::Auth::OAuthService` API for OAuth-2.0-based authentication (aka | ||
OpenID Connect), which can also be used directly without the rest of | ||
the Wt::Auth framework. | ||
|
||
How to run | ||
---------- | ||
|
||
See the README in the parent directory. | ||
|
||
Additional arguments: `-c wt_config.xml` | ||
|
||
The configuration file specifies the configuration for using Google as | ||
an authentication provider (you need to register with Google for this to | ||
work). | ||
|
||
What it illustrates | ||
------------------- | ||
|
||
- the use of many aspects of the `Wt::Auth::OAuthService` (outside the | ||
authentication framework). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<server> | ||
<application-settings location="*"> | ||
<properties> | ||
|
||
<!-- You need to register at google for this to work, and enter | ||
there the same values as you do here. --> | ||
<!-- | ||
<property name="google-oauth2-redirect-endpoint"> | ||
http://localhost:8080/oauth2callback | ||
</property> | ||
<property name="google-oauth2-client-id"> | ||
00000000000.apps.googleusercontent.com | ||
</property> | ||
<property name="google-oauth2-client-secret"> | ||
abcdefghijk-123456789xyz | ||
</property> | ||
--> | ||
</properties> | ||
</application-settings> | ||
</server> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.