From 00e1e9011d80eec399a843bd0c9a3ca9d38823cb Mon Sep 17 00:00:00 2001 From: VargaJoe Date: Mon, 1 Jun 2026 14:37:03 +0200 Subject: [PATCH 1/3] feat: make SMTP SSL setting configurable via EmailSettings - Add EnableSsl property to EmailSettings (default: true) - Use EnableSsl config in EmailService instead of hard-coded true - Add EnableSsl to appsettings.json - Allows disabling SSL for non-secure SMTP servers (e.g., Mailpit on port 1025) - Environment variable override: Email__EnableSsl=false for docker/test environments --- src/sn-auth/Models/Options/EmailSettings.cs | 1 + src/sn-auth/Services/EmailService.cs | 2 +- src/sn-auth/appsettings.json | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sn-auth/Models/Options/EmailSettings.cs b/src/sn-auth/Models/Options/EmailSettings.cs index d18de2e..1d8231c 100644 --- a/src/sn-auth/Models/Options/EmailSettings.cs +++ b/src/sn-auth/Models/Options/EmailSettings.cs @@ -8,4 +8,5 @@ public class EmailSettings public string Password { get; set; } = string.Empty; public string FromEmail { get; set; } = string.Empty; public string FromName { get; set; } = string.Empty; + public bool EnableSsl { get; set; } = true; } diff --git a/src/sn-auth/Services/EmailService.cs b/src/sn-auth/Services/EmailService.cs index d772bec..d73c9e2 100644 --- a/src/sn-auth/Services/EmailService.cs +++ b/src/sn-auth/Services/EmailService.cs @@ -37,7 +37,7 @@ public void SendEmail(string toEmail, string subject, string emailBody) using var client = new SmtpClient(_emailSettings.Server, _emailSettings.Port); if (!string.IsNullOrEmpty(_emailSettings.Username) && !string.IsNullOrEmpty(_emailSettings.Password)) client.Credentials = new NetworkCredential(_emailSettings.Username, _emailSettings.Password); - client.EnableSsl = true; + client.EnableSsl = _emailSettings.EnableSsl; var mailMessage = new MailMessage { diff --git a/src/sn-auth/appsettings.json b/src/sn-auth/appsettings.json index 7bdefba..9cdc43a 100644 --- a/src/sn-auth/appsettings.json +++ b/src/sn-auth/appsettings.json @@ -27,7 +27,8 @@ "Server": "", "Port": 0, "FromEmail": "", - "FromName": "" + "FromName": "", + "EnableSsl": true }, "Registration": { "IsEnabled": false, From 3356c9610cbc9742fb9e8bb23e5a72571b382a98 Mon Sep 17 00:00:00 2001 From: VargaJoe Date: Mon, 1 Jun 2026 15:00:08 +0200 Subject: [PATCH 2/3] ci: add Docker image build/push workflow with manual dispatch --- .github/workflows/docker-image.yml | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..4157d20 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,80 @@ +name: Docker Image CI + +on: + push: + branches: + - 'develop' + - 'main' + - 'master' + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: + - 'develop' + - 'main' + - 'master' + workflow_dispatch: + inputs: + push_image: + description: 'Push the built image to DockerHub' + required: false + default: false + type: boolean + custom_tag: + description: "Optional extra tag (e.g. 'test-xyz'). Branch name is always tagged." + required: false + type: string + +jobs: + build: + runs-on: ubuntu-latest + # Skip draft PRs + if: github.event.pull_request.draft == false || github.event_name == 'push' + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Check if Dockerfile exists + id: check_dockerfile + run: | + if [ -f "src/sn-auth/Dockerfile" ]; then + echo "dockerfile_exists=true" >> $GITHUB_OUTPUT + else + echo "dockerfile_exists=false" >> $GITHUB_OUTPUT + echo "⚠️ No Dockerfile found, skipping Docker build" + fi + + - name: Set up Docker metadata + if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' + id: meta + uses: docker/metadata-action@v5 + with: + images: sensenetcsp/sn-snauth + tags: | + # Clean branch name (e.g., feature-conditional-recaptcha) + type=ref,event=branch + # 'latest' tag only when pushing to main or master (regardless of default branch) + type=raw,value=latest,enable=${{ github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }} + # 'preview' tag only when pushing to develop + type=raw,value=preview,enable=${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} + # PR number for pull requests + type=ref,event=pr + # Optional custom tag from manual workflow_dispatch + type=raw,value=${{ inputs.custom_tag }},enable=${{ github.event_name == 'workflow_dispatch' && inputs.custom_tag != '' }} + + - name: Login to DockerHub + if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image)) + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + if: steps.check_dockerfile.outputs.dockerfile_exists == 'true' + uses: docker/build-push-action@v6 + with: + context: . + file: ./src/sn-auth/Dockerfile + push: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push_image) }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 3cde2c111a107d949e50354cf62d543cb6270b3d Mon Sep 17 00:00:00 2001 From: VargaJoe Date: Mon, 1 Jun 2026 15:03:33 +0200 Subject: [PATCH 3/3] fix image name --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4157d20..08146fe 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,7 +49,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: sensenetcsp/sn-snauth + images: sensenetcsp/sn-auth tags: | # Clean branch name (e.g., feature-conditional-recaptcha) type=ref,event=branch