-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae4fe08
commit b9da6a1
Showing
76 changed files
with
12,663 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: Cloudeko Zenei | ||
release: | ||
current-version: 0.0.1 | ||
next-version: 0.0.1-SNAPSHOT |
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,33 @@ | ||
name: Deploy Docs to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout your repository using git | ||
uses: actions/checkout@v4 | ||
- name: Install, build, and upload your site | ||
uses: withastro/action@v2 | ||
with: | ||
path: ./docs | ||
|
||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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
16 changes: 16 additions & 0 deletions
16
core/src/main/java/dev/cloudeko/zenei/application/web/model/request/LoginRequest.java
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,16 @@ | ||
package dev.cloudeko.zenei.application.web.model.request; | ||
|
||
import jakarta.ws.rs.FormParam; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LoginRequest { | ||
@FormParam("identifier") | ||
private String identifier; | ||
@FormParam("password") | ||
private String password; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...n/web/resource/AdminSettingsResource.java → ...source/backend/AdminSettingsResource.java
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
2 changes: 1 addition & 1 deletion
2
...tion/web/resource/AdminUsersResource.java → .../resource/backend/AdminUsersResource.java
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
2 changes: 1 addition & 1 deletion
2
...cation/web/resource/ExternalResource.java → ...b/resource/frontend/ExternalResource.java
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
34 changes: 34 additions & 0 deletions
34
core/src/main/java/dev/cloudeko/zenei/application/web/resource/frontend/SessionResource.java
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,34 @@ | ||
package dev.cloudeko.zenei.application.web.resource.frontend; | ||
|
||
import dev.cloudeko.zenei.application.web.model.response.TokenResponse; | ||
import dev.cloudeko.zenei.domain.feature.*; | ||
import dev.cloudeko.zenei.domain.model.token.LoginPasswordInput; | ||
import dev.cloudeko.zenei.domain.model.token.RefreshTokenInput; | ||
import dev.cloudeko.zenei.infrastructure.config.ApplicationConfig; | ||
import jakarta.transaction.Transactional; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import lombok.AllArgsConstructor; | ||
import org.eclipse.microprofile.openapi.annotations.tags.Tag; | ||
|
||
@Path("/frontend/session") | ||
@AllArgsConstructor | ||
@Tag(name = "Email Password Service", description = "API for user authentication with email and password") | ||
public class SessionResource { | ||
|
||
private final ApplicationConfig applicationConfig; | ||
private final RefreshAccessToken refreshAccessToken; | ||
|
||
@POST | ||
@Transactional | ||
@Path("/refresh") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response token(@QueryParam("refresh_token") String refreshToken) { | ||
final var token = refreshAccessToken.handle(new RefreshTokenInput(refreshToken)); | ||
return Response.ok(new TokenResponse(token)).build(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
core/src/main/java/dev/cloudeko/zenei/application/web/resource/frontend/UserResource.java
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,42 @@ | ||
package dev.cloudeko.zenei.application.web.resource.frontend; | ||
|
||
import dev.cloudeko.zenei.application.web.model.request.RegisterRequest; | ||
import dev.cloudeko.zenei.application.web.model.response.PrivateUserResponse; | ||
import dev.cloudeko.zenei.application.web.model.response.TokenResponse; | ||
import dev.cloudeko.zenei.domain.feature.*; | ||
import dev.cloudeko.zenei.domain.model.email.EmailAddressInput; | ||
import dev.cloudeko.zenei.domain.model.email.VerifyMagicLinkInput; | ||
import dev.cloudeko.zenei.domain.model.token.LoginPasswordInput; | ||
import dev.cloudeko.zenei.domain.model.token.RefreshTokenInput; | ||
import dev.cloudeko.zenei.infrastructure.config.ApplicationConfig; | ||
import io.quarkus.security.Authenticated; | ||
import jakarta.transaction.Transactional; | ||
import jakarta.validation.Valid; | ||
import jakarta.ws.rs.*; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
import lombok.AllArgsConstructor; | ||
import org.eclipse.microprofile.openapi.annotations.tags.Tag; | ||
|
||
import java.net.URI; | ||
|
||
@Path("/frontend/user") | ||
@AllArgsConstructor | ||
@Tag(name = "User Service", description = "API for user authentication") | ||
public class UserResource { | ||
|
||
private final ApplicationConfig applicationConfig; | ||
private final FindUserByIdentifier findUserByIdentifier; | ||
|
||
@GET | ||
@Authenticated | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response getCurrentUserInfo(@Context SecurityContext securityContext) { | ||
final var userId = Long.parseLong(securityContext.getUserPrincipal().getName()); | ||
final var user = findUserByIdentifier.handle(userId); | ||
|
||
return Response.ok(new PrivateUserResponse(user)).build(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import dev.cloudeko.zenei.profile.DefaultAdminUserProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
|
@@ -23,10 +24,9 @@ public class AuthenticationFlowWithAdminUserTest { | |
@DisplayName("Retrieve all users (GET /admin/users) should return (200 OK)") | ||
void testGetUserInfo() { | ||
final var token = given() | ||
.queryParam("grant_type", "password") | ||
.queryParam("username", "[email protected]") | ||
.queryParam("password", "test") | ||
.post("/user/token") | ||
.formParam("identifier", "[email protected]") | ||
.formParam("password", "test") | ||
.post("/frontend/login") | ||
.then() | ||
.statusCode(Response.Status.OK.getStatusCode()) | ||
.extract().as(TokenResponse.class); | ||
|
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 |
---|---|---|
|
@@ -33,12 +33,11 @@ static void setup() { | |
@DisplayName("Create user via email and password (POST /user) should return (200 OK)") | ||
void testCreateUser() { | ||
given() | ||
.contentType(MediaType.APPLICATION_FORM_URLENCODED) | ||
.formParam("username", "test-user2") | ||
.formParam("email", "[email protected]") | ||
.formParam("password", "test-password") | ||
.formParam("strategy", "PASSWORD") | ||
.post("/user") | ||
.post("/frontend/register") | ||
.then() | ||
.statusCode(Response.Status.OK.getStatusCode()) | ||
.body( | ||
|
@@ -55,17 +54,16 @@ void testCreateUser() { | |
@DisplayName("Retrieve user information (GET /user) should return (200 OK)") | ||
void testGetUserInfo() { | ||
final var token = given() | ||
.queryParam("grant_type", "password") | ||
.queryParam("username", "[email protected]") | ||
.queryParam("password", "test-password") | ||
.post("/user/token") | ||
.formParam("identifier", "[email protected]") | ||
.formParam("password", "test-password") | ||
.post("/frontend/login") | ||
.then() | ||
.statusCode(Response.Status.OK.getStatusCode()) | ||
.extract().as(TokenResponse.class); | ||
|
||
given() | ||
.header("Authorization", "Bearer " + token.getAccessToken()) | ||
.get("/user") | ||
.get("/frontend/user") | ||
.then() | ||
.statusCode(Response.Status.OK.getStatusCode()) | ||
.body( | ||
|
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 |
---|---|---|
|
@@ -24,12 +24,11 @@ static void setup() { | |
@DisplayName("Create user via email and password (POST /user) should return (403 FORBIDDEN)") | ||
void testCreateUser() { | ||
given() | ||
.contentType(MediaType.APPLICATION_FORM_URLENCODED) | ||
.formParam("username", "test-user2") | ||
.formParam("email", "[email protected]") | ||
.formParam("password", "test-password") | ||
.formParam("strategy", "PASSWORD") | ||
.post("/user") | ||
.post("/frontend/register") | ||
.then() | ||
.statusCode(Response.Status.FORBIDDEN.getStatusCode()); | ||
} | ||
|
Oops, something went wrong.