Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bookmarks page #254

Closed
wants to merge 118 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
6f8d586
chore(devops): build backend with actions
atakanyasar Apr 30, 2024
dfbf0df
fix(devops): change to relative path
atakanyasar Apr 30, 2024
290dccc
fix(devops): update docker version
atakanyasar May 1, 2024
8adb285
fix(devops): delete name field in docker-compose.yml
atakanyasar May 1, 2024
00e33ca
fix(devops): test in container
atakanyasar May 1, 2024
1849dd7
fix(devops): revert version changes
atakanyasar May 1, 2024
06dbdb1
chore(devops): improve development compose, add more docs
mmtftr May 6, 2024
7d902b4
Merge pull request #122 from bounswe/devops/feature/docker-improvement
mmtftr May 6, 2024
8e5e3ca
fix(frontend): fix hanging tests by switching to happy-dom
mmtftr May 5, 2024
615cb03
chore(devops): auto-deploy backend staging
atakanyasar May 6, 2024
4877702
feature(frontend): add codegen to the frontend
mmtftr May 7, 2024
077b59f
Merge pull request #129 from bounswe/frontend/fix/hanging-tests
mmtftr May 7, 2024
4542898
Added Icons under assets
NazireAta May 7, 2024
9966413
Added Icons under assets
NazireAta May 7, 2024
f243d4f
chore(devops): use digital ocean access token
atakanyasar May 7, 2024
73702f0
fix(devops): update compose names
atakanyasar May 7, 2024
d0412a2
JWT token & Security Filter chain flow fixed for secured api routes.
EnesBaserr May 7, 2024
a57b200
Merge pull request #134 from bounswe/backend/fix/133-jwt-security-cha…
EnesBaserr May 7, 2024
f1bbada
users/me endpoint implemented.
EnesBaserr May 7, 2024
32df918
Merge pull request #135 from bounswe/backend/feature/124-implement-us…
EnesBaserr May 7, 2024
df3cb17
chore(frontend): add fetcher tests
mmtftr May 7, 2024
3c48620
Entity classes are created & mappings between those entities handled.…
EnesBaserr May 7, 2024
e1f576b
Request matchers defined explicitly so invalid routes does not trigge…
EnesBaserr May 7, 2024
115c183
fix(frontend): some codegen types were fixed
mmtftr May 8, 2024
144716f
chore(api): fix some api spec problems
mmtftr May 8, 2024
431687f
Merge pull request #137 from bounswe/frontend/feature/openapi-codegen
mmtftr May 8, 2024
3899b6a
Merge pull request #142 from bounswe/frontend/feature/130-add-icons
mmtftr May 8, 2024
f84c498
feature(frontend): add react-hook-form to login and signup forms
mmtftr May 8, 2024
dc63fdf
Merge pull request #144 from bounswe/frontend/feature/141-react-hook-…
mmtftr May 8, 2024
90da66e
Merge pull request #140 from bounswe/backend/fix/139-fix-http-response
EnesBaserr May 9, 2024
486fe4b
Merge pull request #145 from bounswe/backend/feature/125-implement-en…
EnesBaserr May 9, 2024
56b481c
Storage mechanism implemented for Cuisine and Dish entitiy according …
EnesBaserr May 9, 2024
773a6e0
Merge pull request #143 from bounswe/devops/fix/116-api-spec
mmtftr May 9, 2024
9ce3230
Search Service rearranged and storage mechanism established.
EnesBaserr May 9, 2024
be32cbf
Merge pull request #158 from bounswe/backend/feature/128-implement-st…
EnesBaserr May 9, 2024
d935a37
Implemented /cuisines/{cuisineId} endpoint
EnesBaserr May 9, 2024
f4e8798
Merge pull request #160 from bounswe/backend/feature/129-cuisines-end…
EnesBaserr May 9, 2024
354c78c
Implemented search/users endpoint
EnesBaserr May 9, 2024
1c017bf
Merge pull request #162 from bounswe/backend/feature/161-search/users…
EnesBaserr May 9, 2024
bbb240c
/users/follow endpoint implemented.
EnesBaserr May 9, 2024
bee886d
Merge pull request #164 from bounswe/backend/feature/163-users/follow…
EnesBaserr May 9, 2024
dd2b5d5
/users/unfollow endpoint implemented.
EnesBaserr May 9, 2024
c04133b
Merge pull request #166 from bounswe/backend/feature/165-users/unfollow
EnesBaserr May 9, 2024
1251839
/follow & /unfollow endpoints now take Path variable (userId)
EnesBaserr May 10, 2024
685d41c
Merge pull request #168 from bounswe/backend/feature/167-rearrange-fo…
EnesBaserr May 10, 2024
fd6db9b
"/{userId}/following" endpoint implemented.
EnesBaserr May 10, 2024
af8dc86
Merge pull request #170 from bounswe/backend/feature/169-/users/{user…
EnesBaserr May 10, 2024
80a2969
"/{userId}/followers" endpoint implemented.
EnesBaserr May 10, 2024
0b4e424
Merge pull request #172 from bounswe/backend/feature/171-/users/{user…
EnesBaserr May 10, 2024
c0d3563
POST "/recipes" endpoint implemented.
EnesBaserr May 10, 2024
bcad331
Merge pull request #181 from bounswe/backend/feature/173-create-recip…
EnesBaserr May 10, 2024
898bd55
DELETE "/recipes" endpoint implemented.
EnesBaserr May 10, 2024
fd1c684
Merge pull request #183 from bounswe/backend/feature/182-delete-recipe
EnesBaserr May 10, 2024
d832a86
POST "recipes/{recipe_id} rating endpoint implemented." Small changes…
EnesBaserr May 10, 2024
f3ff820
Merge pull request #185 from bounswe/backend/feature/184-recipe-rate-…
EnesBaserr May 10, 2024
dd55fb0
Merge remote-tracking branch 'origin/develop' into devops/feature/119…
atakanyasar May 10, 2024
13bfb99
chore(devops): rename to test
atakanyasar May 10, 2024
8c22cb5
fix(devops): add workflow dependency
atakanyasar May 10, 2024
bd77d7b
fix(devops): update compose file names
atakanyasar May 10, 2024
1cce7c1
chore(devops): fix tab indentations
atakanyasar May 10, 2024
69af42c
Merge pull request #132 from bounswe/devops/feature/119-backend-githu…
atakanyasar May 10, 2024
50d8d6e
add bookmarking a recipe functionality
atakanyasar May 10, 2024
ddb34da
get who bookmarked a recipe
atakanyasar May 10, 2024
ef001ed
Merge pull request #186 from bounswe/backend/feature/179-post-bookmark
atakanyasar May 10, 2024
75f562a
Merge pull request #187 from bounswe/backend/feature/178-get-bookmark
atakanyasar May 10, 2024
2a01519
implement get comments
boraykasap May 11, 2024
13b08d9
Merge branch 'develop' into backend/feature/175-get-comments-endpoint
boraykasap May 11, 2024
9a563a4
add frontend github actions
boraykasap May 11, 2024
ec021c2
fix problems
boraykasap May 11, 2024
a3cf436
fix problems
boraykasap May 11, 2024
039fec5
Merge pull request #189 from bounswe/frontend/feature/118-add-github-…
boraykasap May 11, 2024
fc32b2c
fix problems
boraykasap May 11, 2024
cd66295
fix problems
boraykasap May 11, 2024
d314d50
fix problems
boraykasap May 11, 2024
50c5722
fix problems
boraykasap May 12, 2024
32ec451
Merge pull request #188 from bounswe/backend/feature/175-get-comments…
boraykasap May 12, 2024
1b85137
GET /recipes endpoint implemented and entities structure rearranged f…
EnesBaserr May 12, 2024
b16ce15
Merge pull request #194 from bounswe/backend/feature/193-get-/recipes…
EnesBaserr May 13, 2024
ca8e9af
Implemented Recipe Card and Feed Page, also updated RecipeSummay and …
NazireAta May 13, 2024
6b04d5b
GET /recipes/{recieId} endpoint implemented.
EnesBaserr May 13, 2024
85ede56
Merge pull request #198 from bounswe/backend/feature/197-GET-/recipe/…
EnesBaserr May 13, 2024
2c63f0c
GET /feed endpoint implemented
EnesBaserr May 13, 2024
83e1d60
Merge pull request #200 from bounswe/backend/feature/199-/feed-endpoint
EnesBaserr May 13, 2024
6e2d31d
GET users/{userId} endpoint implemented.(User Profile & bookmark reci…
EnesBaserr May 13, 2024
adf4ebb
Merge pull request #202 from bounswe/backend/feature/201-users/{userI…
EnesBaserr May 13, 2024
9b15a89
GET users/{userId} endpoint implemented.(User Profile & bookmark reci…
EnesBaserr May 13, 2024
8044ed0
Merge pull request #204 from bounswe/backend/feature/203-cuisines/{cu…
EnesBaserr May 13, 2024
a992124
Formatting responses for /search (dishes)
EnesBaserr May 13, 2024
98abe2a
Test cases updated.
EnesBaserr May 13, 2024
4f05546
Merge pull request #207 from bounswe/backend/feature/206-formatting-r…
EnesBaserr May 13, 2024
c7d3997
feat(backend): adjust query to search other fields
mmtftr May 14, 2024
bafa11c
chore(devops): remove redundant trigger
mmtftr May 14, 2024
425f602
chore(devops): further limit push trigger
mmtftr May 14, 2024
74b85b1
Merge pull request #214 from bounswe/backend/feature/213-search-fields
mmtftr May 14, 2024
4ebb819
/cuisines/{cuisineId} response format reimplemented.
EnesBaserr May 14, 2024
dee2424
/cuisines/{cuisineId} response format reimplemented.
EnesBaserr May 14, 2024
90f76a6
Merge pull request #220 from bounswe/backend/feature/#219-formatting-…
EnesBaserr May 14, 2024
3cd6155
GET /users/{userId} response format reimplemented.
EnesBaserr May 14, 2024
72e577f
Merge pull request #222 from bounswe/backend/feature/221-/users/{user…
EnesBaserr May 14, 2024
3646bf7
Format GET /users/{userId}/following response
EnesBaserr May 14, 2024
feec97f
Merge pull request #224 from bounswe/backend/feature/223-format-/user…
EnesBaserr May 14, 2024
2e64856
Format GET /users/{userI}/followers response
EnesBaserr May 14, 2024
dcae545
Merge pull request #226 from bounswe/backend/feature/225-format-GET-/…
EnesBaserr May 14, 2024
09b7b45
Format GET /users/follow and /users/unfollow response.
EnesBaserr May 14, 2024
33c8b60
Merge pull request #228 from bounswe/backend/feature/227-Format-POST-…
EnesBaserr May 14, 2024
3264ff6
Format GET /search/users response.
EnesBaserr May 14, 2024
026a04c
Merge pull request #230 from bounswe/backend/feature/229-Format-GET-/…
EnesBaserr May 14, 2024
aff78d0
Format response for /feed .
EnesBaserr May 14, 2024
60d036f
Merge pull request #232 from bounswe/backend/feature/231-Format-respo…
EnesBaserr May 14, 2024
9b04e67
Merge pull request #216 from bounswe/devops/fix/215-remove-redundant-…
mmtftr May 14, 2024
67f66be
Merge branch 'develop' of https://github.com/bounswe/bounswe2024group…
NazireAta May 14, 2024
b079e0c
added comment and comments page
NazireAta May 14, 2024
1655921
added comment and comments page
NazireAta May 14, 2024
82f68c1
added comment and comments page
NazireAta May 14, 2024
daa3ac1
added comment and comments section
NazireAta May 15, 2024
faabafd
added bookmarks page
NazireAta May 15, 2024
aa3554c
added bookmarks page
NazireAta May 15, 2024
c2bdf3b
added bookmarks page
NazireAta May 15, 2024
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
36 changes: 36 additions & 0 deletions .github/workflows/backend_deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: backend-staging-workflow

on:
workflow_run:
workflows: ["backend-test"]
types:
- completed
push:
branches:
- staging
paths:
- 'backend/**'
- compose.yml

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Authorize to with doctl
run: echo ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | doctl auth init --context github-actions

- name: Login to Docker registry
run: doctl registry login --context github-actions

- name: Build Docker image
run: docker compose build

- name: Tag Docker image
run: docker tag bounswe2024group1-backend:latest registry.digitalocean.com/semantic-browse/backend-staging:latest

- name: Push Docker image
run: docker push registry.digitalocean.com/semantic-browse/backend-staging:latest

25 changes: 25 additions & 0 deletions .github/workflows/backend_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: backend-test

on:
push:
paths:
- "backend/**"
- compose.yml
- dev.yml
- ".github/workflows/backend_test.yml"
pull_request:
branches:
- main
- staging

jobs:
test:
runs-on: ubuntu-latest
env:
working-directory: backend
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test with Maven
run: docker compose -f dev.yml run --rm backend mvn test
34 changes: 34 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Front-End CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
cache: 'yarn'

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn install --immutable

- name: Run formatter
run: yarn format

- name: Run linter
run: yarn lint

- name: Run tests
run: yarn test
42 changes: 42 additions & 0 deletions .github/workflows/frontend_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Front-End CI

on:
push:
paths:
- "frontend/**"
- ".github/workflows/frontend_test.yml"
pull_request:
branches:
- main
- staging

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend

steps:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20"
cache: "yarn"

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn install --immutable

- name: Run formatter
run: yarn format

- name: Run linter
run: yarn lint

- name: Run tests
run: yarn test
53 changes: 45 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is the repository for Group1 of SWE course in Spring'24.

This is the repository for the Group1 of the Software Engineering course in Spring'24. The project is a web application that allows users to browse cuisines, dishes, and recipes. The application has a frontend, backend and mobile application. The frontend is a web application that allows users to browse cuisines and recipes. The backend is a REST API that serves the frontend and mobile application. The mobile application is a mobile application that allows users to browse cuisines and recipes.

Please refer to the Wiki for more information.
For common issues when developing, please check [Common Problems](#common-problems). Please refer to the Wiki for more information.

For deploying from scratch (for third-parties), please refer to the [Deployment From Scratch](#deployment-from-scratch) section.

Expand Down Expand Up @@ -35,33 +35,48 @@ You should have Docker installed. Each project has its own requirements however

For deployment, you will need the [DigitalOcean CLI](https://docs.digitalocean.com/reference/doctl/how-to/install/) installed.

We also use Compose Watch for development. For that, your Docker version needs to be at least `2.20.0`.

## Architecture

We have `./frontend`, `./backend` and `./mobile` directories that each contain the respective codebase for the frontend, backend and mobile applications.

Each codebase has its own readme file that explains how to get set up, run the application, and tests. In addition, it is recommended to use the docker-compose setup for development and local test of production builds. We utilize docker-compose to build and deploy the application as well.

In addition, we have our OpenAPI specification at `swagger/openapi.yml`. A Swagger UI instance is available in our docker compose setup at `localhost:8081`.
In addition, we have our OpenAPI specification at `swagger/openapi.yml`. A Swagger UI instance is available in our docker compose setup at `localhost:8081`. In the `mock.yml` file, we have a mock backend server that uses the API spec to generate fake responses.

### Docker Compose

All of the following docker commands are to be run from the root directory (not `frontend` or `backend`).

We have two docker compose setups:

1. (almost) identical to production. uses nginx to host the frontend at port 80, connect at `localhost:80`. Nginx reverse proxies `/api` to the backend at port 8080.

To run the production-like setup, run:

```bash
docker-compose up -d
docker compose up -d
```

2. Development mode. uses the vite development server at port 5173 and exposes it at the same port. This setup will run a development setup that hot reloads the frontend code. The backend code is also run using `mvn spring-boot:run` which means it will reload on recompile. For further detail, refer to the backend README.

```bash
docker-compose -f docker-compose.dev.yml up -d
docker compose -f dev.yml up --watch
```

In addition, you can choose to use the mock API server which will create a mock API server using our API spec. This is useful for frontend development to continue when the backend is lagging behind or not available for some reason.

```bash
docker compose -f dev.yml -f mock.yml up --watch
```

With the hot reloading setup, Vite dev server will hot reload all your changes, however you'll need to restart if you make any changes to package.json as the `node_modules` are fetched as part of the start command.
> [!TIP]
> Note that the `-d` and `--watch` flags can't be combined. If you'd like to run the compose setup detached, you will have to separately run Compose watch using `docker compose -f dev.yml watch`. This is needed for hot-reloading on the frontend.

With the hot reloading setup, Vite dev server will hot reload all your changes, and the image will be rebuilt when `package.json` changes.

To take down the compose setups, you can do a Ctrl+C in the terminal for the development setup or do `docker compose down`. If you're running the development setup in detached mode, you can do `docker compose -f dev.yml down`.

### Development

Expand All @@ -85,15 +100,18 @@ doctl registry login

### Deploying the Application

> [!IMPORTANT]
> Note that you need to use `docker compose` and NOT `docker-compose`. Dashed version is the older version that uses Python and may have conflicts with your local Python environment. We also don't provide `version` which may cause an error with the old Compose V1. For more details, please check [the Docker documentation](https://docs.docker.com/compose/intro/history/).

When you're going to deploy only the application (no changes to infrastructre), you can follow the steps below:

1. Build images using the docker-compose setup.
1. Build images using the docker compose setup.

```bash
docker-compose build
docker compose build
```

2. Tag images for the registry (assuming your project folder is `bounswe2024group1`).
2. Tag images for the registry.

```bash
# for prod
Expand Down Expand Up @@ -199,3 +217,22 @@ doctl apps create --spec .do/app-staging.yml
```

This will create the app and deploy it to the DigitalOcean App Platform. You can now follow the steps above in the normal deployment process to push images and deploy your first instance.

#### Common Problems

##### Compose fails at "yarn install --immutable"

- If the error has "lockfile would have been modified by this install, which is explicitly forbidden".

The `yarn.lock` file is forbidden from changing within the Docker build. This ensures that the same packages are used locally as the ones used inside the Docker image. Solution: do a `yarn install` in the `frontend/` folder.

##### "port is already allocated"

You have something running that is listening on one of the ports of our services. Common reasons include:

- You have the production or the development compose setup running and are trying to run the other one: Check what is running using `docker ps`, if you see other containers that are binding a required port, take them down using the appropriate docker compose command.
- You have another application that is binding a required port. For now, we're binding `8081`, `8080` and `80` for the production setup; and `8081` and `5173` for the development setup.

##### "no such file or directory"

Make sure you run all docker compose commands in the root folder. Make sure you run all `yarn` commands in the `frontend` folder.
22 changes: 21 additions & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
Expand Down Expand Up @@ -65,6 +77,13 @@
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>


<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
Expand All @@ -80,6 +99,7 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>

</dependencies>

<build>
Expand All @@ -88,7 +108,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>

<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
Expand Down
32 changes: 32 additions & 0 deletions backend/src/main/java/com/group1/cuisines/StartupRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.group1.cuisines;

import com.group1.cuisines.entities.Dish;
import com.group1.cuisines.services.WikidataService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
public class StartupRunner implements CommandLineRunner {
@Autowired
private WikidataService wikidataService;

private static final Logger logger = LoggerFactory.getLogger(
WikidataService.class
);
public StartupRunner() {
logger.info("com.group1.cuisines.StartupRunner created");
}


@Override
public void run(String... args) throws Exception {
ArrayList<Dish> dishes = wikidataService.retrieveDishAndCuisineData("");
// You can handle the dishes list here or just check if everything works
logger.info("Data is stored successfully!");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.group1.cuisines.config;

import com.group1.cuisines.services.JwtService;
import com.group1.cuisines.services.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
Expand All @@ -15,6 +17,7 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;

@Configuration
@EnableWebSecurity
Expand All @@ -23,6 +26,9 @@ public class SecurityConfiguration {

private final UserService userService;

private final JwtAuthenticationFilter jwtAuthenticationFilter;


@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http)
throws Exception {
Expand All @@ -32,23 +38,28 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http)
request
.requestMatchers("/api/v1/auth/**")
.permitAll() // Permit all requests to "/api/v1/auth"
.requestMatchers(("GET"), "/api/v1/**")
.requestMatchers("/api/v2/test").authenticated()
.requestMatchers(("GET"), "/**")
.permitAll() // Permit all GET requests
.requestMatchers("/api/v1/admin/**")
.hasRole("ADMIN") // Require ADMIN role for "/api/v1/resources"
.anyRequest()
.authenticated()) // Require authentication for all other requests
.requestMatchers(HttpMethod.POST,"/**")
.authenticated()
.requestMatchers("/feed?type=following").authenticated()
.requestMatchers(HttpMethod.DELETE,"/**").authenticated()) // Require authentication for all other requests
.sessionManagement(
manager ->
manager.sessionCreationPolicy(
SessionCreationPolicy.STATELESS
)
) // Set session creation policy to STATELESS
.authenticationProvider(authenticationProvider()); // Set authentication provider
http.addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);

return http.build();
}


@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
Expand Down
Loading
Loading