Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
45 changes: 45 additions & 0 deletions .github/workflows/maven-deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Maven Deploy Release
on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
MYSQL_RANDOM_ROOT_PASSWORD: yes
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build
run: mvn -B -DbuildVersion=${{ github.event.release.tag_name }} package -Dmaven.test.skip=true
- name: Test
run: mvn -B test
env:
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
MYSQL_USERNAME: test
MYSQL_PASSWORD: test
- name: Install GPG Key
run: echo -e "$GPG_PRIVATE_KEY" | gpg --import --no-tty --batch --yes
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
- name: Deploy to JavaWebStack Repository
run: mvn deploy -B -DbuildVersion=${{ github.event.release.tag_name }} -s build/settings.xml -Dmaven.test.skip=true
env:
DEPLOYMENT_USERNAME: ${{ secrets.DEPLOYMENT_USERNAME }}
DEPLOYMENT_PASSWORD: ${{ secrets.DEPLOYMENT_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,44 @@ Passport is a JWS-Module which allows you to create easily Authentication in you
### Example usage

```java
class MyApp extends WebApplication {
import org.javawebstack.passport.services.oauth2.InteraAppsOAuth2Service;

class MyApp {
/* ... */
protected void setupModules() {
protected void setup() {
HTTPServer httpServer = new HTTPServer().port(1234);

Passport passport = new Passport("/auth");
OAuth2Strategy oAuth2Strategy = new OAuth2Strategy("http://localhost:1234");
oAuth2Strategy.setHttpCallbackHandler((e, callback) -> {
return "Hello " + callback.getProfile().getName();
});

oAuth2Strategy.use("interaapps", new InteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));

passport.use("oauth2", oAuth2Strategy);

OAuth2Module oAuth2Module = new OAuth2Module();
oAuth2Module
.addService(new GithubOAuth2Service("", "", /*Redirect Host*/ "http://localhost:2222"))
.setOAuth2Callback((service, exchange, callback) -> {
System.out.println("Someone logged in with "+service);
return "Hello "+callback.getProfile().name;
});
addModule(oAuth2Module);
passport.createRoutes(httpServer);
httpServer.start();

// Creates Routes: /auth/oauth2/interaapps, /auth/oauth2/interaapps/callback
}


// JWS-Passport ships also an abstracted form of handling oauth2
public void oAuthWithoutHTTPServer() {
OAuth2Strategy oAuth2Strategy = new OAuth2Strategy("http://localhost:1234");
oAuth2Strategy.use("interaapps", new InteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));

// Redirect
String callbackUrl = ".../callback";
String redirectUrl = oAuth2Strategy.get("interaapps").redirect(callbackUrl);

// On callback
OAuth2Callback callback = oAuth2Strategy.get("interaapps").callback(new AbstractObject().set("code", code), callbackUrl);
System.out.println("Hello "+callback.getProfile().name);
}

/* ... */
}
```
Expand All @@ -41,19 +65,6 @@ class MyApp extends WebApplication {
<version>1.0-SNAPSHOT<!-- VERSION --></version>
</dependency>
```
#### or Jitpack
```xml
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>

<dependency>
<groupId>com.github.JavaWebStack</groupId>
<artifactId>Passport</artifactId>
<version>COMMIT_HASH</version>
</dependency>
```

# Services
Service|Class|Control-Panel|More Information
Expand All @@ -63,4 +74,4 @@ Google|GoogleOAuth2Service|[Google Developer Console](https://console.developers
Discord|DiscordOAuth2Service|[Discord Developer Portal](https://discord.com/developers/applications)|-
Facebook|FacebookOAuth2Service|[Facebook Developer Center](https://console.developers.google.com/)|TODO
InteraApps|InteraAppsOAuth2Service|[IA-Accounts Developer Center](https://accounts.interaapps.de/developers/projects)|-
Twitch|TwitchOAuth2Service|[Twitch Developers](https://dev.twitch.tv/)|Implements the OAuth authorization code flow
Twitch|TwitchOAuth2Service|[Twitch Developers](https://dev.twitch.tv/)|Implements the OAuth authorization code flow
115 changes: 88 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,52 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<name>Passport</name>
<description>Adds authentication with ease</description>
<url>https://github.com/JavaWebStack/passport</url>

<groupId>org.javawebstack</groupId>
<artifactId>Passport</artifactId>
<version>1.0-SNAPSHOT</version>
<version>${buildVersion}</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<buildVersion>1.0.1-SNAPSHOT</buildVersion>
</properties>
<repositories>
<repository>
<id>javawebstack</id>
<url>https://repo.javawebstack.org</url>
</repository>
</repositories>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<developers>
<developer>
<name>Julian Gojani</name>
<email>julian@gojani.xyz</email>
<organization>JavaWebStack<!-- & InteraApps --></organization>
<organizationUrl>https://javawebstack.org</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/JavaWebStack/passport.git</connection>
<developerConnection>scm:git:ssh://github.com:JavaWebStack/passport.git</developerConnection>
<url>https://github.com/JavaWebStack/passport/tree/master</url>
</scm>

<dependencies>
<dependency>
<groupId>org.javawebstack</groupId>
<artifactId>Web-Framework</artifactId>
<version>1.0-SNAPSHOT</version>
<artifactId>http-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.javawebstack</groupId>
<artifactId>HTTP-Client</artifactId>
<version>1.0-SNAPSHOT</version>
<artifactId>http-server</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
Expand All @@ -46,28 +66,69 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<id>attach-sources</id>
<goals>
<goal>deploy</goal>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<keyname>A313520526A8DFE1C2A30399C35A3D43C557B112</keyname>
<passphraseServerId>gpg</passphraseServerId>
<gpgArguments>
<arg>--no-tty</arg>
<arg>--batch</arg>
<arg>--yes</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -76,12 +137,12 @@

<distributionManagement>
<snapshotRepository>
<id>javawebstack-snapshots</id>
<url>https://nexus.lumaserv.cloud/repository/javawebstack-snapshots</url>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>javawebstack-releases</id>
<url>https://nexus.lumaserv.cloud/repository/javawebstack-releases</url>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
</project>
9 changes: 0 additions & 9 deletions src/main/java/org/javawebstack/passport/AuthService.java

This file was deleted.

65 changes: 0 additions & 65 deletions src/main/java/org/javawebstack/passport/OAuth2Module.java

This file was deleted.

Loading