Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4a4bf09
FCT : Service d'appel du fournisseur d'Identité
superjekk0 Dec 31, 2025
f395708
FCT : Ajout d'utilisateur valide
superjekk0 Jan 1, 2026
2ec6366
BUGFIX : Appel au point d'entrée Userinfo
superjekk0 Jan 2, 2026
06b7b7a
BUGFIX : Valeurs par défaut manquantes
superjekk0 Jan 2, 2026
dbf501f
PROGRES:added cors policy
Yves-Shaheem May 18, 2026
98ea773
PROGRES: fixed docker file and compose to fit with 8081
Yves-Shaheem May 18, 2026
ff0a672
Fix the the docker-compose.yaml file
Yves-Shaheem Sep 24, 2026
78ae92a
README update
Yves-Shaheem Sep 24, 2026
22dafb3
README update
Yves-Shaheem Sep 24, 2026
e1e06af
fix the missing file
Yves-Shaheem Sep 24, 2026
f783e8a
update env template
Yves-Shaheem Sep 24, 2026
c0bce2c
update README, missing text
Yves-Shaheem Sep 24, 2026
2656450
unified the compose
Yves-Shaheem Sep 24, 2026
755b550
PROGRES : Intégration Docker Compose à Visual Studio 2026
superjekk0 Sep 24, 2026
53d043d
Réparation du Docker Compose
superjekk0 Sep 24, 2026
025325b
FCT : Configuration de l'intégration à Visual Studio
superjekk0 Sep 24, 2026
2fa7dda
Réparation du Workflow
superjekk0 Sep 24, 2026
1991987
FCT : Attachement de débogueur Visual Studio
superjekk0 Sep 24, 2026
3fa0b27
Changement de l'emplacement de compilation cible
superjekk0 Sep 24, 2026
61ef247
Essai 2 de la compilation Docker
superjekk0 Sep 24, 2026
ce6c41e
Rédaction de documentation
superjekk0 Sep 24, 2026
56b0b1f
Suppression de la ConnectionString à la Windows
superjekk0 Sep 25, 2026
cc07c87
Ajout de politique CORS par défaut
superjekk0 Sep 28, 2026
2801a2b
Merge remote-tracking branch 'origin/feature/authentification-authent…
superjekk0 Sep 29, 2026
4e81df5
Normalisation des rôles
superjekk0 Sep 29, 2026
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
7 changes: 4 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/.classpath
**/.dockerignore
**/.env
.env
**/.git
**/.gitignore
**/.project
Expand All @@ -15,7 +15,7 @@
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
Dockerfile
**/node_modules
**/npm-debug.log
**/obj
Expand All @@ -27,4 +27,5 @@ README.md
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
!.git/refs/heads/**
!docker-compose.dcproj
7 changes: 4 additions & 3 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
with:
dotnet-version: 8.x
- name: Restore dependencies
run: dotnet restore
run: dotnet restore Hello.sln
- name: Build
run: dotnet build --no-restore
run: dotnet build Hello.sln --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test Hello.sln --no-build --verbosity normal
docker:
runs-on: ubuntu-latest
needs: [build]
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./core/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
28 changes: 0 additions & 28 deletions Dockerfile

This file was deleted.

10 changes: 8 additions & 2 deletions Hello.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
# Visual Studio Version 18
VisualStudioVersion = 18.10.12217.157 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api.core", "core\api.core.csproj", "{5136ED6D-92F3-4B1E-8E93-3E5FBAA66607}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api.emails", "emails\api.em
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "api.files", "files\api.files.csproj", "{F2425268-5799-42FF-9778-5A1BB7B9DE31}"
EndProject
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{81DDED9D-158B-E303-5F62-77A2896D2A5A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,6 +35,10 @@ Global
{F2425268-5799-42FF-9778-5A1BB7B9DE31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2425268-5799-42FF-9778-5A1BB7B9DE31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2425268-5799-42FF-9778-5A1BB7B9DE31}.Release|Any CPU.Build.0 = Release|Any CPU
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81DDED9D-158B-E303-5F62-77A2896D2A5A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
70 changes: 50 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,48 @@ This API allows to interface the database and handles business functions
## Installation
Different ways can be used to spin up a backend Hello API.

### Create the DB
First of, you need to create a postgreSQL DB if it's not already done.
### Creating the DataBase

> ⚠️ If your database is already created and running, you can skip this step and directly go to [Run the image](#run-the-image).

Access this [repository](https://github.com/ApplETS/Hello-Database-Setup) to get started!
The Docker Compose will create a local instance. If you already have a PostgreSQL instance running on your machine, make sure to deactivate it before booting up the Compose, as it will claim the same port.

### Installation introduction

There is two ways you can install the API:
- Using a docker image: [Docker Installation](#-docker-installation)
There are multiple ways you can install the API:
- Using the docker compose file: [Docker Compose](#-docker-compose)
- Depending on the running parameter you can modify the existing code.
- Using a docker image: [Docker Installation](#-docker-installation) (Deprecated)
- This method doesn't allows you to modify easily the existing code and is more suited for a local server when there is only front-end development to be done.
- Using the classic approach with Visual Studio: [Local Installation](#-local-installation)
- Using Compose with Visual Studio: [Integrated Compose with Visual Studio](#-compose-with-visual-studio)

### 🐳 Docker Compose
After cloning this repository, open it via a terminal or an IDE.
```bash
cd path/to/repo
# With an SSH Key
git clone git@github.com:ApplETS/Backend-Hello.git
# Without an ssh key
git clone https://github.com/ApplETS/Backend-Hello.git
```
You'll need to setup the environment variables in the `.env` file.
Simply copy and paste the `.env.template` file, rename it to `.env` and fill it with the correct values.

Or, in the same directory as this README, run this command and fill it with the correct values:
```bash
cp core/.env.template .env
```
In the same directory as this README, run this the docker compose command:
```bash
docker compose up -d
```

After running the docker compose file, the api should be accessible via:
Comment thread
superjekk0 marked this conversation as resolved.
```bash
# API
http://localhost:8081/api
# SWAGGER
http://localhost:8081/swagger/index.html
```
> ⚠️ Don't forget to rebuild the app after modifying the source code, use the command docker compose up -d --build

### 🐳 Docker Installation
Start by pulling the image from docker hub
Expand All @@ -34,42 +63,43 @@ Simply copy and paste the `.env.template` file, rename it to `.env` and fill it

Then, run the image on your local machine
```bash
docker run --env-file .env --restart always -d -p 8080:8080 -v <PATH_TO_VOLUME_FOLDER>:/app/volume:rw --name ps-api ghcr.io/applets/backend-hello:<VERSION>
docker compose --env-file ./core/.env up -d
```

You can navigate to `http://localhost:8080/swagger` to check if the API is running correctly!
You can navigate to `http://localhost:8081/swagger` to check if the API is running correctly!

### 👷 Local Installation
### 👷 Compose with Visual Studio
You will need a couple of things to get started developing and maintaining Hello-Backend.
- [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install). Should be installed with Docker.
- Docker (suppose to be already installed at this point)
- [Git](https://git-scm.com/downloads)
- Visual Studio 2022 or above version.
- Visual Studio 2022 or above version. (Visual Studio 2026 does not include .NET 8 by default)
- Make sure to check the ASP.NET and web development component
<img width="927" alt="image" src="https://github.com/ApplETS/Backend-Hello/assets/25663435/43d8ce41-2990-445b-9621-8f1418d33f0f">

- .NET8 (which is supposed to come package with VS2022, but in case it's not.)
- .NET 8 (Does come with VS2022, but not VS2026)

NB: Compose is guaranteed to work with a Visual Studio 2026 instance. VS2022 might not work as straightforward.

#### Setup
1. Open Bash, navigate to somewhere you like:
```bash
cd path/to/repo
```
2. Clone the repo using an [ssh key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) or without:
2. Clone the repo using an [ssh key](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) or by HTTPS:
```bash
# With an SSH Key
git clone git@github.com:ApplETS/Backend-Hello.git
# Without an ssh key
# With HTTPS
git clone https://github.com/ApplETS/Backend-Hello.git
```
3. Open the .sln in Visual Studio 2022
4. You'll now need to create your `.env` file from the `.env.template`. You can ask help to fill the empty values from a project maintainer.


#### Running the app using Visual Studio
To run the app make sure to check Docker to run it using docker:

<img width="200" alt="image" src="https://github.com/ApplETS/Backend-Hello/assets/25663435/a1dc7a1f-5e53-4361-9e65-95f284ed29fb">
To run the app, make sure to select the docker-compose startup project: <img width="200" alt="image" src="./readme_assets/compose-vs-startup.png">

Then click on ![image](https://github.com/ApplETS/Backend-Hello/assets/25663435/de874f36-47e0-4e9f-8c8f-9e7e21a67d6c) to run the API.
Then click on ![Docker Compose](https://github.com/ApplETS/Backend-Hello/assets/25663435/de874f36-47e0-4e9f-8c8f-9e7e21a67d6c) to run the API.

You can navigate to http://localhost:8080 where you're app is running.
You can navigate to http://localhost:8081/swagger where the app is running.
16 changes: 12 additions & 4 deletions core/.env.template
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Environment Setup

ASPNETCORE_HTTPS_PORT=8081
ASPNETCORE_HTTP_PORT=8080
ASPNETCORE_ENVIRONMENT=Development
CONNECTION_STRING=Host=db;Port=5432;Username=postgres;Password=test123;Database=ps;

CONNECTION_STRING=User ID=postgres;Password=test123;Host=host.docker.internal;Port=5432;Database=ps;

# Optional for dev
EMAIL_SERVER=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USERNAME=
Expand All @@ -18,14 +17,23 @@ REDIS_CONNECTION_STRING=host.docker.internal:6379,password=eYVX7EwVmmxKPCDmwMtyK
CONTAINER_DIR=/app/volume
CDN_URL=http://localhost:6464

# Communicate with one of the ADMIN to get these information.
OPENID_ISSUER=https://example.com
OPENID_BASE_URL=[Insert your URL here]
OPENID_CLIENT_ID=[Insert your client id here]
OPENID_CLIENT_SECRET=[Insert your client secret here]

FRONTEND_BASE_URL=http://localhost:3000
FRONTEND_BASE_URL=http://localhost:8080
Comment thread
superjekk0 marked this conversation as resolved.

RATE_LIMIT_TIME_WINDOW_SECONDS=10
RATE_LIMIT_MAX_REQUESTS=4

ADMIN_ACCESS_API_KEY=

# The Database services environmental variable
# Default value, if changed check the connection_string
POSTGRES_USER=postgres
POSTGRES_PASSWORD=test123
POSTGRES_DB=postgres
# Directory of CDN
HOST_CDN_DIR=[Insert your CDN directory here]
6 changes: 3 additions & 3 deletions core/Data/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class User
[Flags]
public enum UserRole
{
Admin = 0b10000000,
Moderator = 0b01000000,
Organizer = 0b00100000
Admin = 0x1,
Moderator = 0x2,
Organizer = 0x4
}
28 changes: 13 additions & 15 deletions core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
USER $APP_UID
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
EXPOSE 8082

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ../core/api.core.csproj ./core/
COPY ../emails/api.emails.csproj ./emails/
COPY ../files/api.files.csproj ./files/
COPY ../tests/api.tests.csproj ./tests/
COPY ../Hello.sln ./
RUN dotnet restore
COPY ["core/api.core.csproj", "core/"]
COPY ["emails/api.emails.csproj", "emails/"]
COPY ["files/api.files.csproj", "files/"]
RUN dotnet restore "./core/api.core.csproj"

COPY ../ .
WORKDIR /src
RUN dotnet build -c $BUILD_CONFIGURATION -o /app/build
COPY . .
WORKDIR "/src/core"
RUN dotnet build "./api.core.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
RUN dotnet publish "./api.core.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS runtime
FROM base AS final
WORKDIR /app
COPY --chown=app --from=publish /app/publish .
COPY --chown=$APP_UID --from=publish /app/publish .
RUN mkdir -p /app/volume # create volume directory to store images
ENTRYPOINT ["dotnet", "api.core.dll"]
ENTRYPOINT ["dotnet", "api.core.dll"]
1 change: 1 addition & 0 deletions core/Extensions/DependencyInjectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public static IServiceCollection AddDependencyInjection(this IServiceCollection
services.AddTransient<IImageService, ImageService>();
services.AddTransient<ISubscriptionService, SubscriptionService>();
services.AddTransient<INotificationService, NotificationService>();
services.AddTransient<IIdentityProviderService, AuthentikService>();

// Utils
services.AddTransient<IJwtUtils, JwtUtils>();
Expand Down
15 changes: 12 additions & 3 deletions core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@
builder.Configuration.AddEnvironmentVariables();

builder.Services.AddDbContext<EventManagementContext>(opt => opt.UseNpgsql(connectionString));

builder.Services.AddCors(options =>
{
options.AddPolicy("AllowFrontend",
policy =>
{
policy.WithOrigins(Environment.GetEnvironmentVariable("FRONTEND_BASE_URL")!) // Put your frontend URL here
.AllowAnyHeader()
.AllowAnyMethod();
});
});

var key = Encoding.ASCII.GetBytes(Environment.GetEnvironmentVariable("OPENID_CLIENT_SECRET") ?? "");
builder.Services
Expand Down Expand Up @@ -70,7 +79,7 @@
ValidAudience = Environment.GetEnvironmentVariable("OPENID_CLIENT_ID")
};
// Ensure HTTPS is used (should be true in production)
options.RequireHttpsMetadata = true;
options.RequireHttpsMetadata = false;
});
//.AddOpenIdConnect(options =>
// {
Expand Down Expand Up @@ -181,11 +190,11 @@

app.UseSwagger();
app.UseSwaggerUI();
app.UseCors("AllowFrontend");

app.UseExceptionMiddleware();

// app.UseHttpsRedirection();

app.UseAuthentication();
app.UseAuthorization();

Expand Down
6 changes: 3 additions & 3 deletions core/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5010"
"applicationUrl": "http://localhost:8081"
},
"https": {
"commandName": "Project",
Expand All @@ -35,8 +35,8 @@
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true,
"httpPort": 8080,
"sslPort": 8081,
"httpPort": 8081,
"sslPort": 8082,
"DockerfileRunArguments": "--rm --env-file .env"
}
},
Expand Down
Loading
Loading