mirror of
https://github.com/unraid/api.git
synced 2026-01-01 22:20:05 -06:00
feat: automatic session setup for dev
This commit is contained in:
@@ -96,7 +96,7 @@ onBeforeMount(() => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (devConfig.VITE_MOCK_USER_SESSION && devConfig.NODE_ENV === 'development') {
|
if (devConfig.VITE_MOCK_USER_SESSION && devConfig.NODE_ENV === 'development') {
|
||||||
document.cookie = 'unraid_session_cookie=mock-user-session';
|
document.cookie = 'unraid_session_cookie=mockusersession';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -44,10 +44,8 @@ export type AccessUrlInput = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type AddPermissionInput = {
|
export type AddPermissionInput = {
|
||||||
action: Scalars['String']['input'];
|
actions: Array<Scalars['String']['input']>;
|
||||||
possession: Scalars['String']['input'];
|
|
||||||
resource: Resource;
|
resource: Resource;
|
||||||
role: Role;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AddRoleForApiKeyInput = {
|
export type AddRoleForApiKeyInput = {
|
||||||
@@ -70,6 +68,7 @@ export type ApiKey = {
|
|||||||
description?: Maybe<Scalars['String']['output']>;
|
description?: Maybe<Scalars['String']['output']>;
|
||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
|
permissions: Array<Permission>;
|
||||||
roles: Array<Role>;
|
roles: Array<Role>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -86,6 +85,7 @@ export type ApiKeyWithSecret = {
|
|||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
key: Scalars['String']['output'];
|
key: Scalars['String']['output'];
|
||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
|
permissions: Array<Permission>;
|
||||||
roles: Array<Role>;
|
roles: Array<Role>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -351,8 +351,13 @@ export enum ContainerState {
|
|||||||
|
|
||||||
export type CreateApiKeyInput = {
|
export type CreateApiKeyInput = {
|
||||||
description?: InputMaybe<Scalars['String']['input']>;
|
description?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
/** Whether to create the key in memory only (true), or on disk (false) - memory only keys will not persist through reboots of the API */
|
||||||
|
memory?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
name: Scalars['String']['input'];
|
name: Scalars['String']['input'];
|
||||||
roles: Array<Role>;
|
/** This will replace the existing key if one already exists with the same name, otherwise returns the existing key */
|
||||||
|
overwrite?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
|
permissions?: InputMaybe<Array<AddPermissionInput>>;
|
||||||
|
roles?: InputMaybe<Array<Role>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Devices = {
|
export type Devices = {
|
||||||
@@ -599,7 +604,7 @@ export type Me = UserAccount & {
|
|||||||
description: Scalars['String']['output'];
|
description: Scalars['String']['output'];
|
||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
permissions?: Maybe<Scalars['JSON']['output']>;
|
permissions?: Maybe<Array<Permission>>;
|
||||||
roles: Array<Role>;
|
roles: Array<Role>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1028,6 +1033,12 @@ export type Pci = {
|
|||||||
vendorname?: Maybe<Scalars['String']['output']>;
|
vendorname?: Maybe<Scalars['String']['output']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Permission = {
|
||||||
|
__typename?: 'Permission';
|
||||||
|
actions: Array<Scalars['String']['output']>;
|
||||||
|
resource: Resource;
|
||||||
|
};
|
||||||
|
|
||||||
export type ProfileModel = {
|
export type ProfileModel = {
|
||||||
__typename?: 'ProfileModel';
|
__typename?: 'ProfileModel';
|
||||||
avatar?: Maybe<Scalars['String']['output']>;
|
avatar?: Maybe<Scalars['String']['output']>;
|
||||||
@@ -1196,7 +1207,7 @@ export enum Resource {
|
|||||||
Cloud = 'cloud',
|
Cloud = 'cloud',
|
||||||
Config = 'config',
|
Config = 'config',
|
||||||
Connect = 'connect',
|
Connect = 'connect',
|
||||||
CrashReportingEnabled = 'crash_reporting_enabled',
|
ConnectRemoteAccess = 'connect__remote_access',
|
||||||
Customizations = 'customizations',
|
Customizations = 'customizations',
|
||||||
Dashboard = 'dashboard',
|
Dashboard = 'dashboard',
|
||||||
Disk = 'disk',
|
Disk = 'disk',
|
||||||
@@ -1224,10 +1235,8 @@ export enum Resource {
|
|||||||
/** Available roles for API keys and users */
|
/** Available roles for API keys and users */
|
||||||
export enum Role {
|
export enum Role {
|
||||||
Admin = 'admin',
|
Admin = 'admin',
|
||||||
Guest = 'guest',
|
Connect = 'connect',
|
||||||
MyServers = 'my_servers',
|
Guest = 'guest'
|
||||||
Notifier = 'notifier',
|
|
||||||
Upc = 'upc'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Server = {
|
export type Server = {
|
||||||
@@ -1450,6 +1459,7 @@ export type User = UserAccount & {
|
|||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
/** If the account has a password set */
|
/** If the account has a password set */
|
||||||
password?: Maybe<Scalars['Boolean']['output']>;
|
password?: Maybe<Scalars['Boolean']['output']>;
|
||||||
|
permissions?: Maybe<Array<Permission>>;
|
||||||
roles: Array<Role>;
|
roles: Array<Role>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1457,6 +1467,7 @@ export type UserAccount = {
|
|||||||
description: Scalars['String']['output'];
|
description: Scalars['String']['output'];
|
||||||
id: Scalars['ID']['output'];
|
id: Scalars['ID']['output'];
|
||||||
name: Scalars['String']['output'];
|
name: Scalars['String']['output'];
|
||||||
|
permissions?: Maybe<Array<Permission>>;
|
||||||
roles: Array<Role>;
|
roles: Array<Role>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1678,6 +1689,7 @@ export enum VmState {
|
|||||||
export type Vms = {
|
export type Vms = {
|
||||||
__typename?: 'Vms';
|
__typename?: 'Vms';
|
||||||
domain?: Maybe<Array<VmDomain>>;
|
domain?: Maybe<Array<VmDomain>>;
|
||||||
|
id: Scalars['ID']['output'];
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum WAN_ACCESS_TYPE {
|
export enum WAN_ACCESS_TYPE {
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
import {
|
import { ApolloClient, ApolloLink, createHttpLink, from, Observable, split } from '@apollo/client/core/index.js';
|
||||||
ApolloClient,
|
|
||||||
ApolloLink,
|
|
||||||
createHttpLink,
|
|
||||||
from,
|
|
||||||
Observable,
|
|
||||||
split,
|
|
||||||
} from '@apollo/client/core/index.js';
|
|
||||||
import { onError } from '@apollo/client/link/error/index.js';
|
import { onError } from '@apollo/client/link/error/index.js';
|
||||||
import { RetryLink } from '@apollo/client/link/retry/index.js';
|
import { RetryLink } from '@apollo/client/link/retry/index.js';
|
||||||
import { GraphQLWsLink } from '@apollo/client/link/subscriptions/index.js';
|
import { GraphQLWsLink } from '@apollo/client/link/subscriptions/index.js';
|
||||||
@@ -20,7 +13,7 @@ const httpEndpoint = WEBGUI_GRAPHQL;
|
|||||||
const wsEndpoint = new URL(WEBGUI_GRAPHQL.toString().replace('http', 'ws'));
|
const wsEndpoint = new URL(WEBGUI_GRAPHQL.toString().replace('http', 'ws'));
|
||||||
|
|
||||||
const headers = {
|
const headers = {
|
||||||
'x-csrf-token': globalThis.csrf_token,
|
'x-csrf-token': globalThis.csrf_token ?? '0000000000000000',
|
||||||
};
|
};
|
||||||
|
|
||||||
const httpLink = createHttpLink({
|
const httpLink = createHttpLink({
|
||||||
@@ -108,4 +101,4 @@ export const client = new ApolloClient({
|
|||||||
cache: createApolloCache(),
|
cache: createApolloCache(),
|
||||||
});
|
});
|
||||||
|
|
||||||
provideApolloClient(client);
|
provideApolloClient(client);
|
||||||
@@ -40,11 +40,6 @@ const DOCS_REGISTRATION_REPLACE_KEY = new URL('/go/changing-the-flash-device/',
|
|||||||
|
|
||||||
const SUPPORT = new URL('https://unraid.net');
|
const SUPPORT = new URL('https://unraid.net');
|
||||||
|
|
||||||
// initialize csrf_token in nuxt playground
|
|
||||||
if (import.meta.env.VITE_CSRF_TOKEN) {
|
|
||||||
globalThis.csrf_token = import.meta.env.VITE_CSRF_TOKEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ACCOUNT,
|
ACCOUNT,
|
||||||
ACCOUNT_CALLBACK,
|
ACCOUNT_CALLBACK,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
import { ExclamationTriangleIcon } from '@heroicons/vue/24/solid';
|
import { ExclamationTriangleIcon } from '@heroicons/vue/24/solid';
|
||||||
import { BrandButton, BrandLogo } from '@unraid/ui';
|
import { BrandButton, BrandLogo } from '@unraid/ui';
|
||||||
import { serverState } from '~/_data/serverState';
|
import { serverState } from '~/_data/serverState';
|
||||||
|
import SsoButtonCe from '~/components/SsoButton.ce.vue';
|
||||||
import type { SendPayloads } from '~/store/callback';
|
import type { SendPayloads } from '~/store/callback';
|
||||||
import AES from 'crypto-js/aes';
|
import AES from 'crypto-js/aes';
|
||||||
import SsoButtonCe from '~/components/SsoButton.ce.vue';
|
|
||||||
|
|
||||||
const { registerEntry } = useCustomElements();
|
const { registerEntry } = useCustomElements();
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
@@ -15,6 +15,10 @@ useHead({
|
|||||||
meta: [{ name: 'viewport', content: 'width=1300' }],
|
meta: [{ name: 'viewport', content: 'width=1300' }],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.cookie = 'unraid_session_cookie=mockusersession';
|
||||||
|
});
|
||||||
|
|
||||||
const valueToMakeCallback = ref<SendPayloads | undefined>();
|
const valueToMakeCallback = ref<SendPayloads | undefined>();
|
||||||
const callbackDestination = ref<string>('');
|
const callbackDestination = ref<string>('');
|
||||||
|
|
||||||
@@ -156,7 +160,7 @@ onMounted(() => {
|
|||||||
<div class="bg-background">
|
<div class="bg-background">
|
||||||
<hr class="border-black dark:border-white" />
|
<hr class="border-black dark:border-white" />
|
||||||
<h2 class="text-xl font-semibold font-mono">SSO Button Component</h2>
|
<h2 class="text-xl font-semibold font-mono">SSO Button Component</h2>
|
||||||
<SsoButtonCe :ssoenabled="serverState.ssoEnabled" />
|
<SsoButtonCe :ssoenabled="serverState.ssoEnabled" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</client-only>
|
</client-only>
|
||||||
|
|||||||
Reference in New Issue
Block a user