Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- release/**
- release

jobs:
container-image:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
branches:
- main
pull_request:
branches:
- main
types: [opened, synchronize, reopened]

jobs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { AuthenticationInterceptor } from './authentication.interceptor';

describe('AuthenticationInterceptor', () => {
it('should determine correctly whether authentication is required or not', () => {
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/api`)).toBeTrue();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/api/test`)).toBeTrue();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/api/test/identity`)).toBeTrue();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/api/identity`)).toBeFalse();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/api/identity/test`)).toBeFalse();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/something/api`)).toBeFalse();
expect(AuthenticationInterceptor.doesPathRequireAuthentication(`/something/api/identity`)).toBeFalse();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ import { AuthenticationService } from '../services/authentication.service';

@Injectable()
export class AuthenticationInterceptor implements HttpInterceptor {
private readonly apiRoutesPrefix = `${window.origin}/api`;
private readonly identityRoutesPrefix = `${window.origin}/api/identity`;

constructor(private readonly authenticationService: AuthenticationService) {}

public intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
// IDEA: The check below could maybe be improved with a regex. Also, the API route for changing the user data also
// requires authentication even though its path '/api/identity/user-data/' is excluded by the logic below.
const requireAuthentication = request.url.startsWith(this.apiRoutesPrefix) && !request.url.startsWith(this.identityRoutesPrefix);
if (!request.url.startsWith(window.origin)) {
return next.handle(request);
}

if (!requireAuthentication) {
if (!AuthenticationInterceptor.doesPathRequireAuthentication(request.url.substring(window.origin.length))) {
return next.handle(request);
}

Expand All @@ -30,4 +27,8 @@ export class AuthenticationInterceptor implements HttpInterceptor {
})
);
}

public static doesPathRequireAuthentication(path: string): boolean {
return /^\/api(?!\/identity)/.test(path);
}
}
13 changes: 13 additions & 0 deletions src/Turnierplan.App/Constants/TurnierplanMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Turnierplan.App.Constants;

internal static class TurnierplanMetadata
{
public static readonly string Version = DetermineVersion();

private static string DetermineVersion()
{
var assemblyVersion = typeof(TurnierplanMetadata).Assembly.GetName().Version?.ToString();

return assemblyVersion?[..assemblyVersion.LastIndexOf('.')] ?? "?.?.?";
}
}
9 changes: 5 additions & 4 deletions src/Turnierplan.App/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!doctype html>
@using Turnierplan.App.Constants
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
Expand Down Expand Up @@ -42,11 +43,11 @@
<div class="bg-dark text-white">
<div class="container px-5 py-4 d-flex flex-wrap flex-row">
<div class="footer-section">
<span>turnierplan.NET</span><br/>
<span>turnierplan.NET <span class="small">v@(TurnierplanMetadata.Version)</span></span>
</div>
<div class="footer-section footer-section-right">
<div class="footer-section footer-section-right d-flex">
<a class="text-white text-decoration-none d-flex flex-row align-items-center gap-2" target="_blank" href="https://github.com/turnierplan-NET/turnierplan.NET" rel="noopener">
<img src="./assets/github.svg" alt="GitHub-Logo" />
<img src="./assets/github.svg" alt="GitHub-Logo"/>
<span>GitHub</span>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Turnierplan.App/wwwroot/assets/turnierplan.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ html, body, .overlay-background {
width: 50%;
}

.footer-section-right a {
.footer-section-right {
justify-content: end;
}
}
2 changes: 1 addition & 1 deletion src/version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>0.2.0</Version>
<Version>2025.1.0</Version>
</PropertyGroup>
</Project>
Loading