Skip to content

Latest commit

History

History
76 lines (60 loc) · 3.3 KB

File metadata and controls

76 lines (60 loc) · 3.3 KB



JWS-Passport

GitHub Workflow Status (branch)GitHubLines of codeDiscordTwitter Follow

Introduction

Passport is a JWS-Module which allows you to create easily Authentication in your WebApp. The OAuth2 Support gives you a unified way of implementing OAuth2-Authorization in your WebApp

Example usage

classMyApp {
/* ... */protectedvoidsetup() {
HTTPServerhttpServer = newHTTPServer().port(1234);
Passportpassport = newPassport("/auth");
OAuth2StrategyoAuth2Strategy = newOAuth2Strategy("http://localhost:1234");
oAuth2Strategy.setHttpCallbackHandler((e, callback, name) -> {
return"Hello " + callback.getProfile().getName();
});
oAuth2Strategy.use("google", newGoogleOAuth2Provider("myid", "mysecret").setScopes("https://www.googleapis.com/auth/userinfo.profile", "https://www.googleapis.com/auth/userinfo.email"));
oAuth2Strategy.use("interaapps", newInteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));
passport.use("oauth2", oAuth2Strategy);
passport.createRoutes(httpServer);
httpServer.start();
// Creates Routes: /auth/oauth2/interaapps, /auth/oauth2/interaapps/callback
}
// JWS-Passport ships also an abstracted form of handling oauth2 publicvoidoAuthWithoutHTTPServer() {
OAuth2StrategyoAuth2Strategy = newOAuth2Strategy("http://localhost:1234");
oAuth2Strategy.use("interaapps", newInteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));
// RedirectStringcallbackUrl = ".../callback";
StringredirectUrl = oAuth2Strategy.get("interaapps").redirect(callbackUrl);
// On callbackOAuth2Callbackcallback = oAuth2Strategy.get("interaapps").callback(newAbstractObject().set("code", code), callbackUrl);
System.out.println("Hello " + callback.getProfile().name);
}
/* ... */
}

Dependency

<dependency>
<groupId>org.javawebstack</groupId>
<artifactId>Passport</artifactId>
<version>1.0-SNAPSHOT<!-- VERSION --></version>
</dependency>

Services

ServiceClassControl-PanelMore Information
GithubGithubOAuth2ProviderGithub Developer Center-
GoogleGoogleOAuth2ProviderGoogle Developer Console-
DiscordDiscordOAuth2ProviderDiscord Developer Portal-
FacebookFacebookOAuth2ProviderFacebook Developer CenterTODO
InteraAppsInteraAppsOAuth2ProviderIA-Accounts Developer Center-
TwitchTwitchOAuth2ProviderTwitch DevelopersImplements the OAuth authorization code flow