Skip to content

Commit 96608c6

Browse files
authored
Merge pull request #3 from JavaWebStack/dev
Dev
2 parents 67f439b + 6b9fad0 commit 96608c6

27 files changed

Lines changed: 821 additions & 829 deletions
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Maven Deploy Release
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
services:
10+
mysql:
11+
image: mariadb:latest
12+
env:
13+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
14+
MYSQL_DATABASE: test
15+
MYSQL_USER: test
16+
MYSQL_PASSWORD: test
17+
MYSQL_RANDOM_ROOT_PASSWORD: yes
18+
ports:
19+
- 3306
20+
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up JDK 1.8
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 1.8
27+
- name: Build
28+
run: mvn -B -DbuildVersion=${{ github.event.release.tag_name }} package -Dmaven.test.skip=true
29+
- name: Test
30+
run: mvn -B test
31+
env:
32+
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
33+
MYSQL_USERNAME: test
34+
MYSQL_PASSWORD: test
35+
- name: Install GPG Key
36+
run: echo -e "$GPG_PRIVATE_KEY" | gpg --import --no-tty --batch --yes
37+
env:
38+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
39+
- name: Deploy to JavaWebStack Repository
40+
run: mvn deploy -B -DbuildVersion=${{ github.event.release.tag_name }} -s build/settings.xml -Dmaven.test.skip=true
41+
env:
42+
DEPLOYMENT_USERNAME: ${{ secrets.DEPLOYMENT_USERNAME }}
43+
DEPLOYMENT_PASSWORD: ${{ secrets.DEPLOYMENT_PASSWORD }}
44+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
45+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

‎README.md‎

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,44 @@ Passport is a JWS-Module which allows you to create easily Authentication in you
1515
### Example usage
1616

1717
```java
18-
class MyApp extends WebApplication {
18+
import org.javawebstack.passport.services.oauth2.InteraAppsOAuth2Service;
19+
20+
class MyApp {
1921
/* ... */
20-
protected void setupModules() {
22+
protected void setup() {
23+
HTTPServer httpServer = new HTTPServer().port(1234);
24+
25+
Passport passport = new Passport("/auth");
26+
OAuth2Strategy oAuth2Strategy = new OAuth2Strategy("http://localhost:1234");
27+
oAuth2Strategy.setHttpCallbackHandler((e, callback) -> {
28+
return "Hello " + callback.getProfile().getName();
29+
});
30+
31+
oAuth2Strategy.use("interaapps", new InteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));
32+
33+
passport.use("oauth2", oAuth2Strategy);
2134

22-
OAuth2Module oAuth2Module = new OAuth2Module();
23-
oAuth2Module
24-
.addService(new GithubOAuth2Service("", "", /*Redirect Host*/ "http://localhost:2222"))
25-
.setOAuth2Callback((service, exchange, callback) -> {
26-
System.out.println("Someone logged in with "+service);
27-
return "Hello "+callback.getProfile().name;
28-
});
29-
addModule(oAuth2Module);
35+
passport.createRoutes(httpServer);
36+
httpServer.start();
37+
38+
// Creates Routes: /auth/oauth2/interaapps, /auth/oauth2/interaapps/callback
3039
}
40+
3141

42+
// JWS-Passport ships also an abstracted form of handling oauth2
43+
public void oAuthWithoutHTTPServer() {
44+
OAuth2Strategy oAuth2Strategy = new OAuth2Strategy("http://localhost:1234");
45+
oAuth2Strategy.use("interaapps", new InteraAppsOAuth2Provider("myid", "mysecret").setScopes("user:read"));
46+
47+
// Redirect
48+
String callbackUrl = ".../callback";
49+
String redirectUrl = oAuth2Strategy.get("interaapps").redirect(callbackUrl);
50+
51+
// On callback
52+
OAuth2Callback callback = oAuth2Strategy.get("interaapps").callback(new AbstractObject().set("code", code), callbackUrl);
53+
System.out.println("Hello "+callback.getProfile().name);
54+
}
55+
3256
/* ... */
3357
}
3458
```
@@ -41,19 +65,6 @@ class MyApp extends WebApplication {
4165
<version>1.0-SNAPSHOT<!-- VERSION --></version>
4266
</dependency>
4367
```
44-
#### or Jitpack
45-
```xml
46-
<repository>
47-
<id>jitpack.io</id>
48-
<url>https://jitpack.io</url>
49-
</repository>
50-
51-
<dependency>
52-
<groupId>com.github.JavaWebStack</groupId>
53-
<artifactId>Passport</artifactId>
54-
<version>COMMIT_HASH</version>
55-
</dependency>
56-
```
5768

5869
# Services
5970
Service|Class|Control-Panel|More Information
@@ -63,4 +74,4 @@ Google|GoogleOAuth2Service|[Google Developer Console](https://console.developers
6374
Discord|DiscordOAuth2Service|[Discord Developer Portal](https://discord.com/developers/applications)|-
6475
Facebook|FacebookOAuth2Service|[Facebook Developer Center](https://console.developers.google.com/)|TODO
6576
InteraApps|InteraAppsOAuth2Service|[IA-Accounts Developer Center](https://accounts.interaapps.de/developers/projects)|-
66-
Twitch|TwitchOAuth2Service|[Twitch Developers](https://dev.twitch.tv/)|Implements the OAuth authorization code flow
77+
Twitch|TwitchOAuth2Service|[Twitch Developers](https://dev.twitch.tv/)|Implements the OAuth authorization code flow

‎pom.xml‎

Lines changed: 88 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,52 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7+
<name>Passport</name>
8+
<description>Adds authentication with ease</description>
9+
<url>https://github.com/JavaWebStack/passport</url>
10+
711
<groupId>org.javawebstack</groupId>
812
<artifactId>Passport</artifactId>
9-
<version>1.0-SNAPSHOT</version>
13+
<version>${buildVersion}</version>
1014

1115
<properties>
1216
<maven.compiler.source>8</maven.compiler.source>
1317
<maven.compiler.target>8</maven.compiler.target>
18+
<buildVersion>1.0.1-SNAPSHOT</buildVersion>
1419
</properties>
15-
<repositories>
16-
<repository>
17-
<id>javawebstack</id>
18-
<url>https://repo.javawebstack.org</url>
19-
</repository>
20-
</repositories>
2120

21+
<licenses>
22+
<license>
23+
<name>The Apache License, Version 2.0</name>
24+
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
25+
</license>
26+
</licenses>
27+
28+
<developers>
29+
<developer>
30+
<name>Julian Gojani</name>
31+
<email>julian@gojani.xyz</email>
32+
<organization>JavaWebStack<!-- & InteraApps --></organization>
33+
<organizationUrl>https://javawebstack.org</organizationUrl>
34+
</developer>
35+
</developers>
36+
37+
<scm>
38+
<connection>scm:git:git://github.com/JavaWebStack/passport.git</connection>
39+
<developerConnection>scm:git:ssh://github.com:JavaWebStack/passport.git</developerConnection>
40+
<url>https://github.com/JavaWebStack/passport/tree/master</url>
41+
</scm>
2242

2343
<dependencies>
2444
<dependency>
2545
<groupId>org.javawebstack</groupId>
26-
<artifactId>Web-Framework</artifactId>
27-
<version>1.0-SNAPSHOT</version>
46+
<artifactId>http-client</artifactId>
47+
<version>1.0.0</version>
2848
</dependency>
2949
<dependency>
3050
<groupId>org.javawebstack</groupId>
31-
<artifactId>HTTP-Client</artifactId>
32-
<version>1.0-SNAPSHOT</version>
51+
<artifactId>http-server</artifactId>
52+
<version>1.0.0</version>
3353
</dependency>
3454
<dependency>
3555
<groupId>com.google.apis</groupId>
@@ -46,28 +66,69 @@
4666
<build>
4767
<plugins>
4868
<plugin>
49-
<groupId>org.apache.maven.plugins</groupId>
50-
<artifactId>maven-compiler-plugin</artifactId>
51-
<configuration>
52-
<source>8</source>
53-
<target>8</target>
54-
</configuration>
69+
<artifactId>maven-deploy-plugin</artifactId>
70+
<version>3.0.0-M1</version>
71+
<executions>
72+
<execution>
73+
<id>default-deploy</id>
74+
<phase>deploy</phase>
75+
<goals>
76+
<goal>deploy</goal>
77+
</goals>
78+
</execution>
79+
</executions>
5580
</plugin>
5681
<plugin>
5782
<groupId>org.apache.maven.plugins</groupId>
5883
<artifactId>maven-surefire-plugin</artifactId>
5984
<version>2.22.1</version>
6085
</plugin>
6186
<plugin>
62-
<artifactId>maven-deploy-plugin</artifactId>
63-
<version>3.0.0-M1</version>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-source-plugin</artifactId>
89+
<version>2.2.1</version>
6490
<executions>
6591
<execution>
66-
<id>default-deploy</id>
67-
<phase>deploy</phase>
92+
<id>attach-sources</id>
6893
<goals>
69-
<goal>deploy</goal>
94+
<goal>jar-no-fork</goal>
95+
</goals>
96+
</execution>
97+
</executions>
98+
</plugin>
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-javadoc-plugin</artifactId>
102+
<version>2.9.1</version>
103+
<executions>
104+
<execution>
105+
<id>attach-javadocs</id>
106+
<goals>
107+
<goal>jar</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
<plugin>
113+
<groupId>org.apache.maven.plugins</groupId>
114+
<artifactId>maven-gpg-plugin</artifactId>
115+
<version>3.0.1</version>
116+
<executions>
117+
<execution>
118+
<id>sign-artifacts</id>
119+
<phase>verify</phase>
120+
<goals>
121+
<goal>sign</goal>
70122
</goals>
123+
<configuration>
124+
<keyname>A313520526A8DFE1C2A30399C35A3D43C557B112</keyname>
125+
<passphraseServerId>gpg</passphraseServerId>
126+
<gpgArguments>
127+
<arg>--no-tty</arg>
128+
<arg>--batch</arg>
129+
<arg>--yes</arg>
130+
</gpgArguments>
131+
</configuration>
71132
</execution>
72133
</executions>
73134
</plugin>
@@ -76,12 +137,12 @@
76137

77138
<distributionManagement>
78139
<snapshotRepository>
79-
<id>javawebstack-snapshots</id>
80-
<url>https://nexus.lumaserv.cloud/repository/javawebstack-snapshots</url>
140+
<id>ossrh</id>
141+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
81142
</snapshotRepository>
82143
<repository>
83-
<id>javawebstack-releases</id>
84-
<url>https://nexus.lumaserv.cloud/repository/javawebstack-releases</url>
144+
<id>ossrh</id>
145+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
85146
</repository>
86147
</distributionManagement>
87-
</project>
148+
</project>

‎src/main/java/org/javawebstack/passport/AuthService.java‎

Lines changed: 0 additions & 9 deletions
This file was deleted.

‎src/main/java/org/javawebstack/passport/OAuth2Module.java‎

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)