File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
core/src/node/rpc/anonymous Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1+ import process from 'node:process'
12import * as p from '@clack/prompts'
23import { defineRpcFunction } from '@vitejs/devtools-kit'
34import c from 'ansis'
@@ -19,14 +20,19 @@ export const anonymousAuth = defineRpcFunction({
1920 setup : ( context ) => {
2021 const internal = getInternalContext ( context )
2122 const storage = internal . storage . auth
23+ const isClientAuthDisabled = context . viteConfig . devtools ?. clientAuth === false || process . env . VITE_DEVTOOLS_DISABLE_CLIENT_AUTH === 'true'
24+
25+ if ( isClientAuthDisabled ) {
26+ console . warn ( '[Vite DevTools] Client authentication is disabled. Any browser can connect to the devtools and access to your server and filesystem.' )
27+ }
2228
2329 return {
2430 handler : async ( query : DevToolsAuthInput ) : Promise < DevToolsAuthReturn > => {
2531 const session = context . rpc . getCurrentRpcSession ( )
2632 if ( ! session )
2733 throw new Error ( 'Failed to retrieve the current RPC session' )
2834
29- if ( storage . get ( ) . trusted [ query . authId ] ) {
35+ if ( isClientAuthDisabled || storage . get ( ) . trusted [ query . authId ] ) {
3036 session . meta . clientAuthId = query . authId
3137 session . meta . isTrusted = true
3238 return {
Original file line number Diff line number Diff line change @@ -6,6 +6,22 @@ declare module 'vite' {
66 interface Plugin {
77 devtools ?: DevToolsPluginOptions
88 }
9+ interface UserConfig {
10+ devtools ?: ViteConfigDevtoolsOptions
11+ }
12+ }
13+
14+ export interface ViteConfigDevtoolsOptions {
15+ /**
16+ * Disable client authentication.
17+ *
18+ * Beware that if you disable client authentication,
19+ * any browsers can connect to the devtools and access to your server and filesystem.
20+ * (including other devices, if you open server `host` option to LAN or WAN)
21+ *
22+ * @default true
23+ */
24+ clientAuth ?: boolean
925}
1026
1127export interface PluginWithDevTools extends Plugin {
You can’t perform that action at this time.
0 commit comments