1
0
mirror of https://github.com/pcvolkmer/etl-processor.git synced 2025-04-19 17:26:51 +00:00

Merge pull request #50 from CCC-MF/issue_49

Administrative Rechte für OIDC-Benutzer
This commit is contained in:
Paul-Christian Volkmer 2024-03-04 12:54:31 +01:00 committed by GitHub
commit b332f3c5ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 86 additions and 23 deletions

View File

@ -34,7 +34,8 @@ data class UserRole(
enum class Role(val value: String) { enum class Role(val value: String) {
GUEST("guest"), GUEST("guest"),
USER("user") USER("user"),
ADMIN("admin")
} }
interface UserRoleRepository : CrudRepository<UserRole, Long> { interface UserRoleRepository : CrudRepository<UserRole, Long> {

View File

@ -40,7 +40,7 @@ body {
nav { nav {
margin: 0 auto; margin: 0 auto;
padding: 2em 0; padding: 1em 0;
line-height: 1.5rem; line-height: 1.5rem;
max-width: 1140px; max-width: 1140px;
@ -48,18 +48,18 @@ nav {
border-bottom: 1px solid var(--table-border); border-bottom: 1px solid var(--table-border);
} }
nav > a.nav-home { nav a.nav-home {
float: left; float: left;
color: var(--text); color: var(--text);
line-height: 1.5em; line-height: 1.5em;
text-decoration: none; text-decoration: none;
font-size: 1.5em; font-size: 2em;
font-weight: bold; font-weight: bold;
} }
nav > a.nav-home > img { nav a.nav-home > img {
width: 1.5em; width: 1.5em;
vertical-align: middle; vertical-align: middle;
} }
@ -80,6 +80,57 @@ nav > ul > li.login {
margin: 0 0 0 1em; margin: 0 0 0 1em;
padding: 0 0 0 2em; padding: 0 0 0 2em;
border-left: 1px solid var(--table-border); border-left: 1px solid var(--table-border);
line-height: 3.5em;
}
nav > ul > li.login a {
text-decoration: none;
text-transform: none;
padding: 1em;
}
nav .login .user-name {
font-weight: bold;
}
nav > ul > li.login > span {
display: inline-block;
margin: 0 .5em;
}
nav > ul > li.login .user-icon {
flex-direction: column;
display: inline flex;
vertical-align: middle;
inline-size: 4em;
}
nav > ul > li.login .user-icon img {
margin: 0 0 -1em 0;
width: 80%;
align-self: center;
}
nav > ul > li.login .user-icon span {
padding: 0 .6em;
color: white;
font-size: .8em;
font-weight: bold;
border-radius: 4px;
line-height: normal;
text-align: center;
}
nav > ul > li.login .user-icon span.guest {
background: darkslategray;
}
nav > ul > li.login .user-icon span.user {
background: darkgreen;
}
nav > ul > li.login .user-icon span.admin {
background: darkred;
} }
nav li a { nav li a {
@ -89,10 +140,6 @@ nav li a {
font-weight: 700; font-weight: 700;
} }
nav li.login a {
color: var(--bg-red);
}
nav li a:hover { nav li a:hover {
text-decoration: underline; text-decoration: underline;
} }
@ -449,7 +496,7 @@ td.clipboard.clipped {
} }
.btn.btn-red:hover, .btn.btn-red:active { .btn.btn-red:hover, .btn.btn-red:active {
background: darkred !important; background: darkred;
} }
.btn.btn-blue { .btn.btn-blue {
@ -458,7 +505,7 @@ td.clipboard.clipped {
} }
.btn.btn-blue:hover, .btn.btn-blue:active { .btn.btn-blue:hover, .btn.btn-blue:active {
background: darkslategray !important; background: darkslategray;
} }
.btn.btn-delete:before { .btn.btn-delete:before {
@ -466,6 +513,14 @@ td.clipboard.clipped {
padding: .2rem; padding: .2rem;
} }
button:disabled,
.btn:disabled {
background: slategray !important;
color: lightgray;
filter: none;
cursor: default;
}
input.inline { input.inline {
border: none; border: none;
font-size: 1.1rem; font-size: 1.1rem;

View File

@ -21,16 +21,17 @@
<td> <td>
<div class="userrole-form"> <div class="userrole-form">
<form th:hx-put="@{/configs/userroles/{id}(id=${userRole.id})}" hx-target="#userroles"> <form th:hx-put="@{/configs/userroles/{id}(id=${userRole.id})}" hx-target="#userroles">
<select name="role"> <select name="role" th:disabled="${#authorization.authentication.getName() == userRole.username}">
<option th:selected="${userRole.role.value == 'guest'}" value="GUEST">Gast</option> <option th:selected="${userRole.role.value == 'guest'}" value="GUEST">Gast</option>
<option th:selected="${userRole.role.value == 'user'}" value="USER">Benutzer</option> <option th:selected="${userRole.role.value == 'user'}" value="USER">Benutzer</option>
<option th:selected="${userRole.role.value == 'admin'}" value="ADMIN">Administrator</option>
</select> </select>
<button class="btn btn-blue">Übernehmen</button> <button class="btn btn-blue" th:disabled="${#authorization.authentication.getName() == userRole.username}">Übernehmen</button>
</form> </form>
</div> </div>
</td> </td>
<td> <td>
<button class="btn btn-red" th:hx-delete="@{/configs/userroles/{id}(id=${userRole.id})}" hx-target="#userroles">Löschen</button> <button class="btn btn-red" th:hx-delete="@{/configs/userroles/{id}(id=${userRole.id})}" hx-target="#userroles" th:disabled="${#authorization.authentication.getName() == userRole.username}">Löschen</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -7,10 +7,12 @@
<body> <body>
<div th:fragment="nav"> <div th:fragment="nav">
<nav> <nav>
<span>
<a class="nav-home" th:href="@{/}"> <a class="nav-home" th:href="@{/}">
<img th:src="@{/icon.svg}" alt="Icon" /> <img th:src="@{/icon.svg}" alt="Icon" />
<span>ETL-Processor</span> <span>ETL-Processor</span>
</a> </a>
</span>
<ul> <ul>
<li><a th:href="@{/}">Übersicht</a></li> <li><a th:href="@{/}">Übersicht</a></li>
<li><a th:href="@{/statistics}">Statistiken</a></li> <li><a th:href="@{/statistics}">Statistiken</a></li>
@ -18,15 +20,19 @@
<a th:href="@{/configs}">Konfiguration</a> <a th:href="@{/configs}">Konfiguration</a>
</li> </li>
<li class="login" sec:authorize="not isAuthenticated()"> <li class="login" sec:authorize="not isAuthenticated()">
<a th:href="@{/login}">Login</a> <a class="btn btn-blue" th:href="@{/login}">Login</a>
</li> </li>
<li class="login" sec:authorize="isAuthenticated()"> <li class="login" sec:authorize="isAuthenticated()">
<span> <span>
<span>👤</span> <div class="user-icon">
<span sec:authentication="name">?</span> <img th:src="@{user.svg}" alt="User-Image">
<span sec:authorize="hasRole('ADMIN')" class="user-role admin">Admin</span>
<span sec:authorize="hasRole('USER')" class="user-role user">User</span>
<span sec:authorize="hasRole('GUEST')" class="user-role guest">Guest</span>
</div>
<span class="user-name" sec:authentication="name">?</span>
</span> </span>
&nbsp; <a class="btn btn-red" th:href="@{/logout}">Abmelden</a>
<a th:href="@{/logout}">Abmelden</a>
</li> </li>
</ul> </ul>
</nav> </nav>