Skip to content

Commit 0d1a8ec

Browse files
committed
chore: work on login page
1 parent 551d8bb commit 0d1a8ec

File tree

13 files changed

+283
-590
lines changed

13 files changed

+283
-590
lines changed

spring-boot-admin-samples/spring-boot-admin-sample-servlet/src/main/java/de/codecentric/boot/admin/SecuritySecureConfig.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.springframework.context.annotation.Bean;
2525
import org.springframework.context.annotation.Configuration;
2626
import org.springframework.context.annotation.Profile;
27-
import org.springframework.http.HttpMethod;
2827
import org.springframework.security.config.Customizer;
2928
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
3029
import org.springframework.security.core.userdetails.User;
@@ -70,17 +69,17 @@ protected SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
7069
.requestMatchers(new AntPathRequestMatcher(this.adminServer.path("/login"))).permitAll()
7170
.dispatcherTypeMatchers(DispatcherType.ASYNC).permitAll() // https://github.com/spring-projects/spring-security/issues/11027
7271
.anyRequest().authenticated()) // <2>
73-
.formLogin(formLogin -> formLogin.loginPage(this.adminServer.path("/login"))
74-
.successHandler(successHandler)) // <3>
75-
.logout(logout -> logout.logoutUrl(this.adminServer.path("/logout")))
76-
.httpBasic(Customizer.withDefaults()) // <4>
77-
.csrf(csrf -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) // <5>
78-
.ignoringRequestMatchers(
79-
new AntPathRequestMatcher(this.adminServer.path("/instances"), POST.toString()), // <6>
80-
new AntPathRequestMatcher(this.adminServer.path("/instances/*"), DELETE.toString()), // <6>
81-
new AntPathRequestMatcher(this.adminServer.path("/actuator/**")) // <7>
82-
))
83-
.rememberMe(rememberMe -> rememberMe.key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600));
72+
.formLogin((formLogin) -> formLogin.loginPage(this.adminServer.path("/login"))
73+
.successHandler(successHandler)) // <3>
74+
.logout((logout) -> logout.logoutUrl(this.adminServer.path("/logout")))
75+
.httpBasic(Customizer.withDefaults()) // <4>
76+
.csrf((csrf) -> csrf.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) // <5>
77+
.ignoringRequestMatchers(
78+
new AntPathRequestMatcher(this.adminServer.path("/instances"), POST.toString()), // <6>
79+
new AntPathRequestMatcher(this.adminServer.path("/instances/*"), DELETE.toString()), // <6>
80+
new AntPathRequestMatcher(this.adminServer.path("/actuator/**")) // <7>
81+
))
82+
.rememberMe((rememberMe) -> rememberMe.key(UUID.randomUUID().toString()).tokenValiditySeconds(1209600));
8483
return http.build();
8584

8685
}

spring-boot-admin-server-ui/package-lock.json

Lines changed: 221 additions & 535 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spring-boot-admin-server-ui/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Spring Boot Admin UI",
55
"scripts": {
66
"build": "vite build --emptyOutDir",
7+
"build:dev": "vite build --emptyOutDir --sourcemap --mode development",
78
"build:watch": "vite build --emptyOutDir --watch --sourcemap --mode development",
89
"dev": "vite",
910
"test": "jest",
@@ -20,10 +21,10 @@
2021
"@fortawesome/free-regular-svg-icons": "5.15.4",
2122
"@fortawesome/free-solid-svg-icons": "5.15.4",
2223
"@fortawesome/vue-fontawesome": "3.0.0-5",
23-
"@headlessui/vue": "1.7.0",
24+
"@headlessui/vue": "1.7.4",
2425
"@stekoe/vue-toast-notificationcenter": "https://github.com/SteKoe/vue-toast-notificationcenter/archive/refs/tags/1.0.0-RC3.tar.gz",
25-
"@tailwindcss/forms": "0.5.0",
26-
"@tailwindcss/typography": "0.5.2",
26+
"@tailwindcss/forms": "0.5.3",
27+
"@tailwindcss/typography": "0.5.8",
2728
"ansi_up": "5.1.0",
2829
"autolinker": "3.15.0",
2930
"axios": "0.26.1",
@@ -48,9 +49,9 @@
4849
"resize-observer-polyfill": "1.5.1",
4950
"rxjs": "7.5.5",
5051
"v3-infinite-loading": "1.0.6",
51-
"vue": "3.2.33",
52-
"vue-i18n": "9.1.9",
53-
"vue-router": "4.0.16",
52+
"vue": "3.2.45",
53+
"vue-i18n": "9.2.2",
54+
"vue-router": "4.1.6",
5455
"vue3-click-away": "1.2.4"
5556
},
5657
"devDependencies": {

spring-boot-admin-server-ui/src/main/frontend/components/sba-alert.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
<template>
1818
<div
1919
v-if="hasError"
20-
class="rounded-b px-4 py-3 shadow-sm backdrop-filter backdrop-blur-xs bg-opacity-80 my-3"
2120
:class="classNames(alertClass, borderClassNames)"
21+
class="rounded-b px-4 py-3 shadow-sm backdrop-filter backdrop-blur-xs bg-opacity-80 my-3"
2222
role="alert"
2323
>
2424
<div class="flex">
2525
<div class="py-1">
26-
<font-awesome-icon :icon="icon" prefix="fa" size="1x" class="mr-4" />
26+
<font-awesome-icon :icon="icon" class="mr-4" prefix="fa" size="1x" />
2727
</div>
2828
<div class="grid grid-cols-1 place-content-center">
2929
<p v-if="title" class="font-bold" v-text="title" />
@@ -54,7 +54,7 @@ export default {
5454
default: undefined,
5555
},
5656
error: {
57-
type: [Error, String],
57+
type: [Error, String, Event],
5858
default: null,
5959
},
6060
severity: {

spring-boot-admin-server-ui/src/main/frontend/i18n/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const i18n = createI18n({
3939
? browserLanguage
4040
: 'en',
4141
fallbackLocale: 'en',
42+
legacy: false,
4243
silentFallbackWarn: process.env.NODE_ENV === 'production',
4344
silentTranslationWarn: process.env.NODE_ENV === 'production',
4445
messages,

spring-boot-admin-server-ui/src/main/frontend/login.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
id="login"
4848
></section>
4949

50+
<script lang="javascript" src="sba-settings.js"></script>
5051
<script type="module" lang="javascript" src="./login.js"></script>
5152
</body>
5253
</html>

spring-boot-admin-server-ui/src/main/frontend/login/login.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<div :class="{ 'has-errors': error }" class="pb-4 form-group">
2020
<sba-input
2121
:label="t('login.placeholder.username')"
22+
autocomplete="username"
2223
name="username"
2324
type="text"
2425
/>
@@ -28,6 +29,12 @@
2829
name="password"
2930
type="password"
3031
/>
32+
<sba-checkbox
33+
v-if="rememberMeEnabled"
34+
:label="t('login.remember_me')"
35+
class="justify-end"
36+
name="remember-me"
37+
/>
3138
</div>
3239
</div>
3340
</div>
@@ -44,15 +51,18 @@
4451
</template>
4552

4653
<script setup>
47-
import { computed, defineProps } from 'vue';
54+
import { computed } from 'vue';
4855
import { useI18n } from 'vue-i18n';
4956
5057
import SbaAlert, { Severity } from '@/components/sba-alert';
5158
import SbaButton from '@/components/sba-button';
59+
import SbaCheckbox from '@/components/sba-checkbox';
5260
import SbaInput from '@/components/sba-input';
5361
import SbaPanel from '@/components/sba-panel';
5462
import SbaWave from '@/components/sba-wave';
5563
64+
import sbaConfig from '@/sba-config';
65+
5666
const i18n = useI18n();
5767
const t = i18n.t;
5868
@@ -79,14 +89,16 @@ const props = defineProps({
7989
},
8090
});
8191
92+
const { rememberMeEnabled } = sbaConfig.uiSettings;
93+
8294
const error = computed(() => {
8395
let errors = props.param.error;
8496
8597
if (Array.isArray(errors)) {
8698
if (errors.includes('401')) {
8799
return t('login.error.login_required', { code: errors[0] });
88100
} else {
89-
return t('login.invalid_username_or_password');
101+
return t('login.error.invalid_username_or_password');
90102
}
91103
} else {
92104
return undefined;

spring-boot-admin-server-ui/src/main/frontend/mocks/applications/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { applications } from './data.js';
44

55
const applicationsEndpoint = [
66
rest.get('/applications', (req, res, ctx) => {
7-
return res(ctx.status(200), ctx.json(applications));
7+
return res(ctx.status(404), ctx.json(applications));
88
}),
99
];
1010

spring-boot-admin-server-ui/src/main/frontend/sba-config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const DEFAULT_CONFIG = {
2626
},
2727
color: '#42d3a5',
2828
},
29+
notifications: {
30+
enabled: true,
31+
},
2932
rememberMeEnabled: true,
3033
externalViews: [],
3134
favicon: 'assets/img/favicon.png',

spring-boot-admin-server-ui/src/main/frontend/shell/index.vue

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,9 @@
1616

1717
<template>
1818
<div id="app">
19-
<SbaNavbar
20-
:applications="applications"
21-
:error="error"
22-
:applications-initialized="applicationsInitialized"
23-
/>
19+
<SbaNavbar :error="error" />
2420
<div class="sba-container">
25-
<router-view
26-
:applications="applications"
27-
:error="error"
28-
:applications-initialized="applicationsInitialized"
29-
/>
21+
<router-view :error="error" />
3022
</div>
3123
</div>
3224
</template>
@@ -40,10 +32,6 @@ defineProps({
4032
type: Error,
4133
default: null,
4234
},
43-
applicationsInitialized: {
44-
type: Boolean,
45-
default: false,
46-
},
4735
});
4836
4937
const { applications } = useApplicationStore();

0 commit comments

Comments
 (0)