Skip to content

Commit 7d3c597

Browse files
committed
feat: Implement authentication and basic navigation
1 parent d6fa0a5 commit 7d3c597

File tree

25 files changed

+539
-43
lines changed

25 files changed

+539
-43
lines changed

apps/spuxx-client/.env.local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_API_URL=http://localhost:8080
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
worker_processes 4;
3+
4+
events { worker_connections 1024; }
5+
6+
error_log stderr;
7+
pid /tmp/nginx.pid;
8+
9+
http {
10+
server {
11+
listen 8080;
12+
root /usr/share/nginx/html;
13+
include /etc/nginx/mime.types;
14+
15+
location / {
16+
root /usr/share/nginx/html;
17+
try_files $uri $uri/ /index.html;
18+
index index.html index.htm;
19+
}
20+
21+
location /alive {
22+
default_type application/json;
23+
return 200 '{ "status": "ok" }';
24+
}
25+
26+
location /status {
27+
stub_status on;
28+
}
29+
30+
location /injected-config.js {
31+
alias /usr/share/nginx/html/config/injected-config.js;
32+
expires -1;
33+
}
34+
35+
error_page 500 502 503 504 /50x.html;
36+
location = /50x.html {
37+
root /usr/share/nginx/html;
38+
}
39+
}
40+
}

apps/spuxx-client/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
},
1212
"license": "MIT",
1313
"devDependencies": {
14+
"@modyfi/vite-plugin-yaml": "1.1.0",
1415
"@tailwindcss/vite": "^4.1.5",
1516
"tailwindcss": "^4.1.5",
1617
"typescript": "^5.7.2",
1718
"vite": "^6.0.0",
18-
"vite-plugin-solid": "^2.11.6"
19+
"vite-plugin-solid": "^2.11.6",
20+
"vite-tsconfig-paths": "5.1.4"
1921
},
2022
"dependencies": {
2123
"@solidjs/router": "^0.15.3",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
main:
3+
page:
4+
login:
5+
login-via-oidc: Anmelden via auth.spuxx.dev
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type { LogLevel } from '@spuxx/js-utils';
2+
3+
export interface AppConfig {
4+
/**
5+
* The URL of the api service.
6+
*/
7+
API_URL: string;
8+
/**
9+
* The URL of the IDP's account service page.
10+
*/
11+
ACCOUNT_SERVICE_URL: string;
12+
/**
13+
* The default locale of the application.
14+
*/
15+
DEFAULT_LOCALE: string;
16+
/**
17+
* The log level of the application.
18+
*/
19+
LOG_LEVEL: LogLevel;
20+
}
21+
22+
export const appConfig: AppConfig = {
23+
API_URL: 'https://api.spuxx.dev',
24+
ACCOUNT_SERVICE_URL: 'https://auth.spuxx.dev/realms/main/account',
25+
DEFAULT_LOCALE: 'de',
26+
LOG_LEVEL: 'debug',
27+
};
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import { Button, Container } from '@spuxx/solid';
22
import { Component } from 'solid-js';
3+
import { SessionService } from '../../../services/session';
4+
import { useNavigate } from '@solidjs/router';
5+
import { intl } from '@spuxx/js-utils';
36

47
export const LoginPage: Component = () => {
8+
const navigate = useNavigate();
9+
10+
async function checkAuthentication() {
11+
const isAuthenticated = await SessionService.isAuthenticated();
12+
if (isAuthenticated) navigate('/', { replace: true });
13+
}
14+
checkAuthentication();
15+
16+
async function handleLogin() {
17+
SessionService.login();
18+
}
19+
520
return (
621
<Container class="relative text-center justify-center top-1/2 -translate-y-1/2">
722
<h1>my.spuxx.dev</h1>
8-
<Button icon="mdi:login">Anmelden via auth.spuxx.dev</Button>
23+
<Button icon="mdi:login" onClick={handleLogin}>
24+
{intl('main.page.login.login-via-oidc')}
25+
</Button>
926
</Container>
1027
);
1128
};

apps/spuxx-client/src/features/main/pages/root.page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { SessionService } from '@/services/session';
12
import { Component } from 'solid-js';
23

34
export const RootPage: Component = () => {
5+
SessionService.protectRoute();
6+
47
return (
58
<div>
69
<h1>Root Page</h1>

apps/spuxx-client/src/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ import { render } from 'solid-js/web';
33

44
import './styles/index.css';
55
import App from './App';
6+
import { Config } from '@spuxx/browser-utils';
7+
import { appConfig, AppConfig } from './config/app.config';
8+
import { Intl, Logger } from '@spuxx/js-utils';
9+
import de from '@/assets/locales/de.yaml';
10+
11+
Config.setup<AppConfig>({
12+
defaultConfig: appConfig,
13+
importMetaEnv: import.meta.env,
14+
});
15+
Logger.setLevel(Config.getConfig<AppConfig>().LOG_LEVEL);
16+
17+
Intl.setup({
18+
fallbackLocale: Config.getConfig<AppConfig>().DEFAULT_LOCALE,
19+
dictionaries: [
20+
{
21+
locale: 'de',
22+
values: de,
23+
},
24+
],
25+
});
626

727
const root = document.getElementById('root');
828

apps/spuxx-client/src/layout/side-nav/side-nav.component.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const SideNav = () => {
2424
color="text-default"
2525
onClick={Layout.closeSidebarOnMobile}
2626
/>
27+
<ButtonLink
28+
icon="mdi:login"
29+
title="Login"
30+
href="/login"
31+
variant="colored"
32+
color="text-default"
33+
onClick={Layout.closeSidebarOnMobile}
34+
/>
2735
<Button
2836
icon="mdi:account"
2937
title="Account"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { RouteProps } from '@solidjs/router';
2-
import { mainRoutes } from '../features/main/main.routes';
2+
import { mainRoutes } from '@/features/main/main.routes';
33

44
export const routes: RouteProps<string, never>[] = [...mainRoutes];

0 commit comments

Comments
 (0)