1 
2 /*
3  * SessionConstants.hpp
4  *
5  * Copyright (C) 2021 by RStudio, PBC
6  *
7  * Unless you have received this program directly from RStudio pursuant
8  * to the terms of a commercial license agreement with RStudio, then
9  * this program is licensed to you under the terms of version 3 of the
10  * GNU Affero General Public License. This program is distributed WITHOUT
11  * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
13  * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
14  *
15  */
16 
17 #ifndef SESSION_CONSTANTS_HPP
18 #define SESSION_CONSTANTS_HPP
19 
20 #define kEventsPending                    "ep"
21 
22 #define kRStudioUserIdentity              "RSTUDIO_USER_IDENTITY"
23 #define kRStudioSystemUserIdentity        "X-RStudioSystemUserIdentity"
24 #define kRStudioUserIdentityDisplay       "X-RStudioUserIdentity"
25 #define kRStudioLimitRpcClientUid         "RSTUDIO_LIMIT_RPC_CLIENT_UID"
26 #define kRSessionPortNumber               "RSTUDIO_SESSION_PORT"
27 #define kRSessionStandalonePortNumber     "RSTUDIO_STANDALONE_PORT"
28 #define kRStudioSessionStream             "RSTUDIO_SESSION_STREAM"
29 #define kRStudioMultiSession              "RSTUDIO_MULTI_SESSION"
30 #define kRStudioSessionScopeProject       "RSTUDIO_SESSION_SCOPE_PROJECT"
31 #define kRStudioSessionScopeId            "RSTUDIO_SESSION_SCOPE_ID"
32 #define kRStudioSessionRoute              "RSTUDIO_SESSION_ROUTE"
33 #define kRStudioRequiredUserGroup         "RSTUDIO_REQUIRED_USER_GROUP"
34 #define kRStudioMinimumUserId             "RSTUDIO_MINIMUM_USER_ID"
35 #define kRStudioSigningKey                "RSTUDIO_SIGNING_KEY"
36 #define kRStudioVersion                   "RSTUDIO_VERSION"
37 #define kRSessionRsaPublicKey             "RSTUDIO_SESSION_RSA_PUBLIC_KEY"
38 #define kRSessionRsaPrivateKey            "RSTUDIO_SESSION_RSA_PRIVATE_KEY"
39 #define kRStudioSessionUserLicenseSoftLimitReached "RSTUDIO_SESSION_USER_LICENSE_SOFT_LIMIT_REACHED"
40 
41 #define kRStudioDefaultRVersion           "RSTUDIO_DEFAULT_R_VERSION"
42 #define kRStudioDefaultRVersionHome       "RSTUDIO_DEFAULT_R_VERSION_HOME"
43 
44 #define kRStudioUserHomePage              "RSTUDIO_USER_HOME_PAGE"
45 
46 #define kProgramModeSessionOption         "program-mode"
47 #define kRStudioProgramMode               "RSTUDIO_PROGRAM_MODE"
48 #define kSessionProgramModeDesktop        "desktop"
49 #define kSessionProgramModeServer         "server"
50 
51 #define kShowUserIdentitySessionOption    "show-user-identity"
52 #define kUserIdentitySessionOption        "user-identity"
53 #define kUserIdentitySessionOptionShort   "u"
54 
55 #define kProjectSessionOption             "project"
56 #define kProjectSessionOptionShort        "p"
57 
58 #define kScopeSessionOption               "scope"
59 #define kScopeSessionOptionShort          "s"
60 
61 #define kVerifyInstallationSessionOption  "verify-installation"
62 
63 #define kRunTestsSessionOption            "run-tests"
64 #define kRunScriptSessionOption           "run-script"
65 
66 #define kVersionSessionOption             "version"
67 
68 #define kLimitSessionOption               "session-limit"
69 #define kTimeoutSessionOption             "session-timeout-minutes"
70 #define kTimeoutSuspendSessionOption      "session-timeout-suspend"
71 #define kDisconnectedTimeoutSessionOption "session-disconnected-timeout-minutes"
72 #define kSessionEphemeralEnvVars          "session-ephemeral-env-vars"
73 #define kVerifySignaturesSessionOption    "verify-signatures"
74 #define kStandaloneSessionOption          "standalone"
75 #define kWwwAddressSessionOption          "www-address"
76 #define kWwwPortSessionOption             "www-port"
77 #define kWwwResusePorts                   "www-reuse-ports"
78 #define kTerminalPortOption               "terminal-port"
79 #define kSessionSuspendOnIncompleteStatement "session-suspend-on-incomplete-statement"
80 #define kSessionAsyncRpcEnabled           "session-async-rpc-enabled"
81 #define kSessionAsyncRpcTimeoutMs         "session-async-rpc-timeout-ms"
82 #define kSessionHandleOfflineEnabled      "session-handle-offline-enabled"
83 #define kSessionHandleOfflineTimeoutMs    "session-handle-offline-timeout-ms"
84 
85 #define kLauncherSessionOption            "launcher-session"
86 
87 #define kWebSocketPingInterval            "websocket-ping-seconds"
88 #define kWebSocketConnectTimeout          "websocket-connect-timeout"
89 #define kWebSocketLogLevel                "websocket-log-level"
90 #define kWebSocketHandshakeTimeout        "websocket-handshake-timeout"
91 
92 #define kPackageOutputInPackageFolder     "package-output-to-package-folder"
93 
94 #define kRootPathSessionOption            "session-root-path"
95 #define kUseSecureCookiesSessionOption    "session-use-secure-cookies"
96 #define kSameSiteSessionOption            "session-same-site"
97 
98 // NOTE: literal versions of these are depended upon by the desktop/rsinverse
99 // project so they should be updated there as well if they are changed
100 #define kLocalUriLocationPrefix           "/rsession-local/"
101 #define kPostbackUriScope                 "postback/"
102 #define kPostbackExitCodeHeader           "X-Postback-ExitCode"
103 
104 #define kMonitoredPath      "monitored"
105 #define kListsPath          "lists"
106 #define kProjectMruList     "project_mru"
107 
108 #define kServerHomeSetting     "showUserHomePage"
109 #define kServerHomeAlways      "always"
110 #define kServerHomeNever       "never"
111 #define kServerHomeSessions    "sessions"
112 
113 #define kReuseSessionsForProjectLinksSettings "reuseSessionsForProjectLinks"
114 
115 #define kRStudioNoTransformRedirect "X-RStudio-NoTransformRedirect"
116 
117 #define kSessionProxyDefaultPort   "8789"
118 #define kRStudioSessionProxyPort   "X-RStudio-Session-Proxy-Port"
119 
120 #define kSessionUserLicenseSoftLimitReached  "session-user-license-soft-limit-reached"
121 
122 #define kRestoreWorkspaceNo       0
123 #define kRestoreWorkspaceYes      1
124 #define kRestoreWorkspaceDefault  2
125 
126 #define kRunRprofileNo       0
127 #define kRunRprofileYes      1
128 #define kRunRprofileDefault  2
129 
130 #define kSessionTmpDirEnvVar       "RS_SESSION_TMP_DIR"
131 #define kSessionTmpDir             "rstudio-rsession"
132 
133 #define kDefaultPandocPath         "bin/pandoc"
134 #define kDefaultPostbackPath       "bin/postback/rpostback"
135 #define kDefaultRsclangPath        "bin/rsclang"
136 
137 // json rpc methods we handle (the rest are delegated to the HttpServer)
138 const char * const kClientInit = "client_init";
139 const char * const kEditCompleted = "edit_completed";
140 const char * const kChooseFileCompleted = "choose_file_completed";
141 const char * const kLocatorCompleted = "locator_completed";
142 const char * const kUserPromptCompleted = "user_prompt_completed";
143 const char * const kAdminNotificationAcknowledged = "admin_notification_acknowledged";
144 const char * const kHandleUnsavedChangesCompleted = "handle_unsaved_changes_completed";
145 const char * const kQuitSession = "quit_session";
146 const char * const kSuspendSession = "suspend_session";
147 const char * const kInterrupt = "interrupt";
148 const char * const kConsoleInput = "console_input";
149 const char * const kRStudioAPIShowDialogMethod = "rstudio_api_show_dialog";
150 
151 // session exit codes - note max value supported by Linux is 255
152 #define SESSION_EXIT_CODE_OFFSET              200
153 #define SESSION_EXIT_SCOPE_INVALID_SESSION    SESSION_EXIT_CODE_OFFSET + 1
154 #define SESSION_EXIT_SCOPE_INVALID_PROJECT    SESSION_EXIT_CODE_OFFSET + 2
155 #define SESSION_EXIT_SCOPE_MISSING_PROJECT    SESSION_EXIT_CODE_OFFSET + 3
156 #define SESSION_EXIT_INVALID_RPC_CONFIG       SESSION_EXIT_CODE_OFFSET + 4
157 
158 #endif // SESSION_CONSTANTS_HPP
159 
160