Skip to content

Commit 5f0ede1

Browse files
committed
Show guidance if authorization is disabled
1 parent 209f4fb commit 5f0ede1

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/Frontend/src/components/configuration/UserPermissions.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,15 @@ export const groups: ApplicationCapabilityGroup[] = [
8989

9090
<script setup lang="ts">
9191
import { computed } from "vue";
92+
import { storeToRefs } from "pinia";
9293
import { faCheck, faXmark } from "@fortawesome/free-solid-svg-icons";
9394
import FAIcon from "@/components/FAIcon.vue";
9495
import ConditionalRender from "@/components/ConditionalRender.vue";
9596
import { useAllowedRoutes } from "@/composables/useAllowedRoutes";
97+
import { useAuthStore } from "@/stores/AuthStore";
9698
9799
const { canCall, supported, roles } = useAllowedRoutes();
100+
const { authorizationEnabled } = storeToRefs(useAuthStore());
98101
99102
const rows = computed(() =>
100103
groups.map((g) => ({
@@ -130,7 +133,21 @@ const rows = computed(() =>
130133
</div>
131134
</template>
132135

133-
<table class="permissions-table">
136+
<div v-if="authorizationEnabled === false" class="container not-supported">
137+
<div class="row">
138+
<div class="col-sm-12">
139+
<div class="text-center message">
140+
<p>Role-based access control is not enabled.</p>
141+
<p>Control who can see and do what in ServicePulse. Role-based authorization lets you restrict failed message retries, endpoint management, and other sensitive actions to the right people.</p>
142+
<div>
143+
<a class="btn btn-default btn-primary" href="https://docs.particular.net/servicecontrol/security/configuration/authorization" target="_blank">Learn how to enable authorization</a>
144+
</div>
145+
</div>
146+
</div>
147+
</div>
148+
</div>
149+
150+
<table v-else class="permissions-table">
134151
<thead>
135152
<tr>
136153
<th scope="col" class="area-col">Area</th>

src/Frontend/src/stores/AuthStore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import serviceControlClient from "@/components/serviceControlClient";
88

99
interface AuthConfigResponse {
1010
enabled: boolean;
11+
// Absent on ServiceControl versions older than the one that introduced this field.
12+
role_based_authorization_enabled?: boolean;
1113
client_id: string;
1214
authority: string;
1315
api_scopes: string;
@@ -21,6 +23,8 @@ export const useAuthStore = defineStore("auth", () => {
2123
const authError = ref<string | null>(null);
2224
const authConfig = ref<AuthConfig | null>(null);
2325
const authEnabled = ref(false);
26+
// undefined means ServiceControl didn't report this field (older version) — treat as enabled.
27+
const authorizationEnabled = ref<boolean | undefined>(undefined);
2428
const loading = ref(true);
2529

2630
async function refresh() {
@@ -29,6 +33,7 @@ export const useAuthStore = defineStore("auth", () => {
2933
const config = await getAuthConfig();
3034
if (config) {
3135
authEnabled.value = config.enabled;
36+
authorizationEnabled.value = config.role_based_authorization_enabled;
3237
authConfig.value = config.enabled ? transformToAuthConfig(config) : null;
3338
}
3439
} finally {
@@ -108,6 +113,7 @@ export const useAuthStore = defineStore("auth", () => {
108113
authError,
109114
authConfig,
110115
authEnabled,
116+
authorizationEnabled,
111117
loading,
112118
refresh,
113119
setToken,

src/Frontend/test/preconditions/authentication.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as precondition from ".";
77
*/
88
export interface AuthConfigResponse {
99
enabled: boolean;
10+
role_based_authorization_enabled: boolean;
1011
client_id: string;
1112
authority: string;
1213
api_scopes: string;
@@ -19,6 +20,7 @@ export interface AuthConfigResponse {
1920
*/
2021
export const authDisabledConfig: AuthConfigResponse = {
2122
enabled: false,
23+
role_based_authorization_enabled: false,
2224
client_id: "",
2325
authority: "",
2426
api_scopes: "[]",
@@ -31,6 +33,7 @@ export const authDisabledConfig: AuthConfigResponse = {
3133
*/
3234
export const authEnabledConfig: AuthConfigResponse = {
3335
enabled: true,
36+
role_based_authorization_enabled: true,
3437
client_id: "servicepulse-test",
3538
authority: "https://login.microsoftonline.com/test-tenant-id/v2.0",
3639
api_scopes: '["api://servicecontrol/access_as_user"]',

0 commit comments

Comments
 (0)