Skip to content

Commit 36d630e

Browse files
committed
feat: automatic session setup for dev
1 parent 5981693 commit 36d630e

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

web/components/UserProfile.ce.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ onBeforeMount(() => {
9696
9797
onMounted(() => {
9898
if (devConfig.VITE_MOCK_USER_SESSION && devConfig.NODE_ENV === 'development') {
99-
document.cookie = 'unraid_session_cookie=mock-user-session';
99+
document.cookie = 'unraid_session_cookie=mockusersession';
100100
}
101101
})
102102
</script>

web/composables/gql/graphql.ts

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ export type AccessUrlInput = {
4444
};
4545

4646
export type AddPermissionInput = {
47-
action: Scalars['String']['input'];
48-
possession: Scalars['String']['input'];
47+
actions: Array<Scalars['String']['input']>;
4948
resource: Resource;
50-
role: Role;
5149
};
5250

5351
export type AddRoleForApiKeyInput = {
@@ -70,6 +68,7 @@ export type ApiKey = {
7068
description?: Maybe<Scalars['String']['output']>;
7169
id: Scalars['ID']['output'];
7270
name: Scalars['String']['output'];
71+
permissions: Array<Permission>;
7372
roles: Array<Role>;
7473
};
7574

@@ -86,6 +85,7 @@ export type ApiKeyWithSecret = {
8685
id: Scalars['ID']['output'];
8786
key: Scalars['String']['output'];
8887
name: Scalars['String']['output'];
88+
permissions: Array<Permission>;
8989
roles: Array<Role>;
9090
};
9191

@@ -351,8 +351,13 @@ export enum ContainerState {
351351

352352
export type CreateApiKeyInput = {
353353
description?: InputMaybe<Scalars['String']['input']>;
354+
/** Whether to create the key in memory only (true), or on disk (false) - memory only keys will not persist through reboots of the API */
355+
memory?: InputMaybe<Scalars['Boolean']['input']>;
354356
name: Scalars['String']['input'];
355-
roles: Array<Role>;
357+
/** This will replace the existing key if one already exists with the same name, otherwise returns the existing key */
358+
overwrite?: InputMaybe<Scalars['Boolean']['input']>;
359+
permissions?: InputMaybe<Array<AddPermissionInput>>;
360+
roles?: InputMaybe<Array<Role>>;
356361
};
357362

358363
export type Devices = {
@@ -599,7 +604,7 @@ export type Me = UserAccount & {
599604
description: Scalars['String']['output'];
600605
id: Scalars['ID']['output'];
601606
name: Scalars['String']['output'];
602-
permissions?: Maybe<Scalars['JSON']['output']>;
607+
permissions?: Maybe<Array<Permission>>;
603608
roles: Array<Role>;
604609
};
605610

@@ -1028,6 +1033,12 @@ export type Pci = {
10281033
vendorname?: Maybe<Scalars['String']['output']>;
10291034
};
10301035

1036+
export type Permission = {
1037+
__typename?: 'Permission';
1038+
actions: Array<Scalars['String']['output']>;
1039+
resource: Resource;
1040+
};
1041+
10311042
export type ProfileModel = {
10321043
__typename?: 'ProfileModel';
10331044
avatar?: Maybe<Scalars['String']['output']>;
@@ -1196,7 +1207,7 @@ export enum Resource {
11961207
Cloud = 'cloud',
11971208
Config = 'config',
11981209
Connect = 'connect',
1199-
CrashReportingEnabled = 'crash_reporting_enabled',
1210+
ConnectRemoteAccess = 'connect__remote_access',
12001211
Customizations = 'customizations',
12011212
Dashboard = 'dashboard',
12021213
Disk = 'disk',
@@ -1224,10 +1235,8 @@ export enum Resource {
12241235
/** Available roles for API keys and users */
12251236
export enum Role {
12261237
Admin = 'admin',
1227-
Guest = 'guest',
1228-
MyServers = 'my_servers',
1229-
Notifier = 'notifier',
1230-
Upc = 'upc'
1238+
Connect = 'connect',
1239+
Guest = 'guest'
12311240
}
12321241

12331242
export type Server = {
@@ -1450,13 +1459,15 @@ export type User = UserAccount & {
14501459
name: Scalars['String']['output'];
14511460
/** If the account has a password set */
14521461
password?: Maybe<Scalars['Boolean']['output']>;
1462+
permissions?: Maybe<Array<Permission>>;
14531463
roles: Array<Role>;
14541464
};
14551465

14561466
export type UserAccount = {
14571467
description: Scalars['String']['output'];
14581468
id: Scalars['ID']['output'];
14591469
name: Scalars['String']['output'];
1470+
permissions?: Maybe<Array<Permission>>;
14601471
roles: Array<Role>;
14611472
};
14621473

@@ -1678,6 +1689,7 @@ export enum VmState {
16781689
export type Vms = {
16791690
__typename?: 'Vms';
16801691
domain?: Maybe<Array<VmDomain>>;
1692+
id: Scalars['ID']['output'];
16811693
};
16821694

16831695
export enum WAN_ACCESS_TYPE {

web/helpers/create-apollo-client.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
ApolloClient,
3-
ApolloLink,
4-
createHttpLink,
5-
from,
6-
Observable,
7-
split,
8-
} from '@apollo/client/core/index.js';
1+
import { ApolloClient, ApolloLink, createHttpLink, from, Observable, split } from '@apollo/client/core/index.js';
92
import { onError } from '@apollo/client/link/error/index.js';
103
import { RetryLink } from '@apollo/client/link/retry/index.js';
114
import { GraphQLWsLink } from '@apollo/client/link/subscriptions/index.js';
@@ -20,7 +13,7 @@ const httpEndpoint = WEBGUI_GRAPHQL;
2013
const wsEndpoint = new URL(WEBGUI_GRAPHQL.toString().replace('http', 'ws'));
2114

2215
const headers = {
23-
'x-csrf-token': globalThis.csrf_token,
16+
'x-csrf-token': globalThis.csrf_token ?? '0000000000000000',
2417
};
2518

2619
const httpLink = createHttpLink({
@@ -108,4 +101,4 @@ export const client = new ApolloClient({
108101
cache: createApolloCache(),
109102
});
110103

111-
provideApolloClient(client);
104+
provideApolloClient(client);

web/helpers/urls.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ const DOCS_REGISTRATION_REPLACE_KEY = new URL('/go/changing-the-flash-device/',
4040

4141
const SUPPORT = new URL('https://unraid.net');
4242

43-
// initialize csrf_token in nuxt playground
44-
if (import.meta.env.VITE_CSRF_TOKEN) {
45-
globalThis.csrf_token = import.meta.env.VITE_CSRF_TOKEN;
46-
}
47-
4843
export {
4944
ACCOUNT,
5045
ACCOUNT_CALLBACK,

web/pages/index.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { ExclamationTriangleIcon } from '@heroicons/vue/24/solid';
33
import { BrandButton, BrandLogo } from '@unraid/ui';
44
import { serverState } from '~/_data/serverState';
5+
import SsoButtonCe from '~/components/SsoButton.ce.vue';
56
import type { SendPayloads } from '~/store/callback';
67
import AES from 'crypto-js/aes';
7-
import SsoButtonCe from '~/components/SsoButton.ce.vue';
88
99
const { registerEntry } = useCustomElements();
1010
onBeforeMount(() => {
@@ -15,6 +15,10 @@ useHead({
1515
meta: [{ name: 'viewport', content: 'width=1300' }],
1616
});
1717
18+
onMounted(() => {
19+
document.cookie = 'unraid_session_cookie=mockusersession';
20+
});
21+
1822
const valueToMakeCallback = ref<SendPayloads | undefined>();
1923
const callbackDestination = ref<string>('');
2024
@@ -156,7 +160,7 @@ onMounted(() => {
156160
<div class="bg-background">
157161
<hr class="border-black dark:border-white" />
158162
<h2 class="text-xl font-semibold font-mono">SSO Button Component</h2>
159-
<SsoButtonCe :ssoenabled="serverState.ssoEnabled" />
163+
<SsoButtonCe :ssoenabled="serverState.ssoEnabled" />
160164
</div>
161165
</div>
162166
</client-only>

0 commit comments

Comments
 (0)