Skip to content

Commit 1844eef

Browse files
committed
Implemented initial session token exchange.
1 parent 0bc15ca commit 1844eef

17 files changed

Lines changed: 119 additions & 54 deletions

File tree

Shuttle.Access.Application/RegisterSessionParticipant.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async Task SaveAsync()
146146

147147
await _sessionTokenExchangeRepository.SaveAsync(sessionTokenExchange, context.CancellationToken);
148148

149-
message.WithSessionTokenExchangeUrl($"{message.KnownApplicationOptions!.SessionTokenExchangeUrl}/{sessionTokenExchange.ExchangeToken}");
149+
message.WithSessionTokenExchangeUrl($"{message.KnownApplicationOptions!.SessionTokenExchangeUrl.TrimEnd('/')}/{sessionTokenExchange.ExchangeToken}");
150150
}
151151
}
152152
}

Shuttle.Access.Vue/package-lock.json

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

Shuttle.Access.Vue/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@mdi/font": "7.4.47",
1515
"@vuelidate/core": "^2.0.3",
1616
"@vuelidate/validators": "^2.0.4",
17+
"@vueuse/core": "^12.4.0",
1718
"axios": "^1.7.9",
1819
"moment": "^2.30.1",
1920
"roboto-fontface": "*",

Shuttle.Access.Vue/src/access.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export type SessionResponse = {
128128
result: string;
129129
token: string;
130130
tokenExpiryDate: string;
131-
exchangeTokenUrl?: string;
131+
sessionTokenExchangeUrl?: string;
132132
};
133133

134134
export type SessionStoreState = {
@@ -137,5 +137,4 @@ export type SessionStoreState = {
137137
identityName?: string;
138138
token?: string;
139139
permissions: SessionPermission[];
140-
applicationName?: string;
141140
};

Shuttle.Access.Vue/src/components/Navbar.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const items = computed(() => {
6666
const result: any[] = [];
6767
6868
map.forEach((item: NavigationItem) => {
69-
var add = false;
70-
7169
if (!item.permission || sessionStore.hasPermission(item.permission)) {
7270
result.push({
7371
title: t(item.title),

Shuttle.Access.Vue/src/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"deactivated": "Deactivated",
1414
"exceptions": {
1515
"oauth-error": "An error occurred while attempting to authenticate with the OAuth provider: {error}",
16-
"session-initialize": "Your session has expired. Please sign in again.",
1716
"invalid-credentials": "Invalid credentials.",
1817
"insufficient-permission": "You do not have permission to access the requested view. Please contact your system administrator if you require access."
1918
},
@@ -68,6 +67,7 @@
6867
"status": "Status",
6968
"submit": "Submit",
7069
"table-empty": "(no results)",
70+
"token": "Token",
7171
"identity-required": "No identities have been registered. You will be registered as an administrator.",
7272
"yes": "Yes"
7373
}

Shuttle.Access.Vue/src/main.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,20 @@ app.use(router);
2020

2121
registerPlugins(app);
2222

23-
const alertStore = useAlertStore();
2423
const sessionStore = useSessionStore();
2524

2625
if (window.location.pathname !== "/oauth") {
2726
await sessionStore.initialize().catch((error) => {
28-
alertStore.add({
29-
message: i18n.global.t("exceptions.session-initialize", {
30-
error: error.toString(),
31-
}),
32-
type: "error",
33-
name: "session-initialize",
34-
});
35-
36-
router.push({ path: "/signin" });
27+
if (!window.location.pathname.startsWith("/signin")) {
28+
router.push({ path: "/signin" });
29+
}
3730
});
3831
}
3932

40-
if (window.location.pathname === "/") {
33+
if (
34+
window.location.pathname === "/" ||
35+
window.location.pathname === "/signin"
36+
) {
4137
router.push({ path: sessionStore.authenticated ? "/dashboard" : "/signin" });
4238
}
4339

Shuttle.Access.Vue/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const routes: Array<RouteRecordRaw> = [
4141
},
4242
},
4343
{
44-
path: "/oauth/:",
44+
path: "/oauth",
4545
name: "oauth",
4646
component: () => import("../views/OAuth.vue"),
4747
},

Shuttle.Access.Vue/src/stores/session.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export const useSessionStore = defineStore("session", {
2424
status(): string {
2525
return !this.token ? "not-signed-in" : "signed-in";
2626
},
27-
applicationName(): string | undefined {
28-
return this.applicationName;
29-
},
3027
},
3128
actions: {
3229
async initialize() {

Shuttle.Access.Vue/src/views/OAuth.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ onMounted(() => {
4949
var data = response.data;
5050
var params = { identityName: data.identityName };
5151
52+
if (response.data.sessionTokenExchangeUrl) {
53+
window.location.replace(response.data.sessionTokenExchangeUrl);
54+
55+
return;
56+
}
57+
5258
if (data.result === "UnknownIdentity") {
5359
alertStore.add({
5460
message: data.registrationRequested ? t("messages.oauth-unknown-identity-registered", params) : t("messages.oauth-unknown-identity", params),
@@ -62,8 +68,6 @@ onMounted(() => {
6268
}
6369
6470
router.push({ name: "dashboard" });
65-
66-
alertStore.remove("session-initialize");
6771
})
6872
.catch(error => {
6973
alertStore.add({

0 commit comments

Comments
 (0)