Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
41300c35
Commit
41300c35
authored
Nov 13, 2015
by
Eddú Meléndez
Committed by
Stephane Nicoll
Nov 13, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add timeout configuration for CRaSH
Closes gh-4325
parent
0c8d302a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
12 deletions
+57
-12
ShellProperties.java
...framework/boot/actuate/autoconfigure/ShellProperties.java
+28
-0
CrshAutoConfigurationTests.java
...oot/actuate/autoconfigure/CrshAutoConfigurationTests.java
+27
-12
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+2
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java
View file @
41300c35
...
...
@@ -36,6 +36,7 @@ import org.springframework.util.StringUtils;
*
* @author Christian Dupuis
* @author Phillip Webb
* @author Eddú Meléndez
*/
@ConfigurationProperties
(
prefix
=
"shell"
,
ignoreUnknownFields
=
true
)
public
class
ShellProperties
{
...
...
@@ -242,10 +243,22 @@ public class ShellProperties {
*/
private
Integer
port
=
2000
;
/**
* Number of milliseconds after which unused connections are closed.
*/
private
Integer
idleTimeout
=
600000
;
/**
* Number of milliseconds after user will be prompted to login again.
*/
private
Integer
authTimeout
=
600000
;
@Override
protected
void
applyToCrshShellConfig
(
Properties
config
)
{
if
(
this
.
enabled
)
{
config
.
put
(
"crash.ssh.port"
,
String
.
valueOf
(
this
.
port
));
config
.
put
(
"crash.ssh.auth_timeout"
,
String
.
valueOf
(
this
.
authTimeout
));
config
.
put
(
"crash.ssh.idle_timeout"
,
String
.
valueOf
(
this
.
idleTimeout
));
if
(
this
.
keyPath
!=
null
)
{
config
.
put
(
"crash.ssh.keypath"
,
this
.
keyPath
);
}
...
...
@@ -278,6 +291,21 @@ public class ShellProperties {
return
this
.
port
;
}
public
Integer
getIdleTimeout
()
{
return
this
.
idleTimeout
;
}
public
void
setIdleTimeout
(
Integer
idleTimeout
)
{
this
.
idleTimeout
=
idleTimeout
;
}
public
Integer
getAuthTimeout
()
{
return
this
.
authTimeout
;
}
public
void
setAuthTimeout
(
Integer
authTimeout
)
{
this
.
authTimeout
=
authTimeout
;
}
}
/**
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfigurationTests.java
View file @
41300c35
...
...
@@ -62,6 +62,7 @@ import static org.junit.Assert.assertTrue;
*
* @author Christian Dupuis
* @author Andreas Ahlenstorf
* @author Eddú Meléndez
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
class
CrshAutoConfigurationTests
{
...
...
@@ -80,10 +81,7 @@ public class CrshAutoConfigurationTests {
MockEnvironment
env
=
new
MockEnvironment
();
env
.
setProperty
(
"shell.disabled_plugins"
,
"GroovyREPL, termIOHandler, org.crsh.auth.AuthenticationPlugin"
);
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setEnvironment
(
env
);
this
.
context
.
register
(
CrshAutoConfiguration
.
class
);
this
.
context
.
refresh
();
load
(
env
);
PluginLifeCycle
lifeCycle
=
this
.
context
.
getBean
(
PluginLifeCycle
.
class
);
assertNotNull
(
lifeCycle
);
...
...
@@ -112,14 +110,13 @@ public class CrshAutoConfigurationTests {
MockEnvironment
env
=
new
MockEnvironment
();
env
.
setProperty
(
"shell.ssh.enabled"
,
"true"
);
env
.
setProperty
(
"shell.ssh.port"
,
"3333"
);
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setEnvironment
(
env
);
this
.
context
.
register
(
CrshAutoConfiguration
.
class
);
this
.
context
.
refresh
();
load
(
env
);
PluginLifeCycle
lifeCycle
=
this
.
context
.
getBean
(
PluginLifeCycle
.
class
);
assertEquals
(
"3333"
,
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.port"
));
assertEquals
(
"600000"
,
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.auth_timeout"
));
assertEquals
(
"600000"
,
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.idle_timeout"
));
}
@Test
...
...
@@ -127,10 +124,7 @@ public class CrshAutoConfigurationTests {
MockEnvironment
env
=
new
MockEnvironment
();
env
.
setProperty
(
"shell.ssh.enabled"
,
"true"
);
env
.
setProperty
(
"shell.ssh.key_path"
,
"~/.ssh/id.pem"
);
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setEnvironment
(
env
);
this
.
context
.
register
(
CrshAutoConfiguration
.
class
);
this
.
context
.
refresh
();
load
(
env
);
PluginLifeCycle
lifeCycle
=
this
.
context
.
getBean
(
PluginLifeCycle
.
class
);
...
...
@@ -138,6 +132,27 @@ public class CrshAutoConfigurationTests {
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.keypath"
));
}
@Test
public
void
testSshConfigurationCustomTimeouts
()
{
MockEnvironment
env
=
new
MockEnvironment
();
env
.
setProperty
(
"shell.ssh.enabled"
,
"true"
);
env
.
setProperty
(
"shell.ssh.auth-timeout"
,
"300000"
);
env
.
setProperty
(
"shell.ssh.idle-timeout"
,
"300000"
);
load
(
env
);
PluginLifeCycle
lifeCycle
=
this
.
context
.
getBean
(
PluginLifeCycle
.
class
);
assertEquals
(
"300000"
,
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.auth_timeout"
));
assertEquals
(
"300000"
,
lifeCycle
.
getConfig
().
getProperty
(
"crash.ssh.idle_timeout"
));
}
private
void
load
(
MockEnvironment
env
)
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setEnvironment
(
env
);
this
.
context
.
register
(
CrshAutoConfiguration
.
class
);
this
.
context
.
refresh
();
}
@Test
public
void
testCommandResolution
()
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
41300c35
...
...
@@ -846,7 +846,9 @@ content into your application; rather pick only the properties that you need.
shell.config-path-patterns=classpath*:/crash/* # Patterns to use to look for configurations.
shell.disabled-commands=jpa*,jdbc*,jndi* # Comma-separated list of commands to disable.
shell.disabled-plugins= # Comma-separated list of plugins to disable. Certain plugins are disabled by default based on the environment.
shell.ssh.auth-timeout = # Number of milliseconds after user will be prompted to login again.
shell.ssh.enabled=true # Enable CRaSH SSH support.
shell.ssh.idle-timeout = # Number of milliseconds after which unused connections are closed.
shell.ssh.key-path= # Path to the SSH server key.
shell.ssh.port=2000 # SSH port.
shell.telnet.enabled=false # Enable CRaSH telnet support. Enabled by default if the TelnetPlugin is available.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment