Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
f85eb32b
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f85eb32b
编写于
7月 26, 2011
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
split the security setup into a separate section
上级
f854eca1
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
149 addition
and
61 deletion
+149
-61
core/src/main/java/hudson/security/GlobalSecurityConfiguration.java
...ain/java/hudson/security/GlobalSecurityConfiguration.java
+62
-0
core/src/main/java/jenkins/model/Jenkins.java
core/src/main/java/jenkins/model/Jenkins.java
+9
-23
core/src/main/resources/hudson/security/GlobalSecurityConfiguration/config.groovy
...hudson/security/GlobalSecurityConfiguration/config.groovy
+78
-0
core/src/main/resources/jenkins/model/Jenkins/configure.jelly
.../src/main/resources/jenkins/model/Jenkins/configure.jelly
+0
-38
未找到文件。
core/src/main/java/hudson/security/GlobalSecurityConfiguration.java
0 → 100644
浏览文件 @
f85eb32b
/*
* The MIT License
*
* Copyright (c) 2011, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.security
;
import
hudson.Extension
;
import
hudson.markup.MarkupFormatter
;
import
jenkins.model.GlobalConfiguration
;
import
jenkins.model.Jenkins
;
import
net.sf.json.JSONObject
;
import
org.kohsuke.stapler.StaplerRequest
;
/**
* Security configuration.
*
* @author Kohsuke Kawaguchi
*/
@Extension
(
ordinal
=
200
)
public
class
GlobalSecurityConfiguration
extends
GlobalConfiguration
{
@Override
public
boolean
configure
(
StaplerRequest
req
,
JSONObject
json
)
throws
FormException
{
// for compatibility reasons, the actual value is stored in Jenkins
Jenkins
j
=
Jenkins
.
getInstance
();
if
(
json
.
has
(
"useSecurity"
))
{
JSONObject
security
=
json
.
getJSONObject
(
"useSecurity"
);
j
.
setSecurityRealm
(
SecurityRealm
.
all
().
newInstanceFromRadioList
(
security
,
"realm"
));
j
.
setAuthorizationStrategy
(
AuthorizationStrategy
.
all
().
newInstanceFromRadioList
(
security
,
"authorization"
));
if
(
security
.
has
(
"markupFormatter"
))
{
j
.
setMarkupFormatter
(
req
.
bindJSON
(
MarkupFormatter
.
class
,
security
.
getJSONObject
(
"markupFormatter"
)));
}
else
{
j
.
setMarkupFormatter
(
null
);
}
}
else
{
j
.
disableSecurity
();
}
return
true
;
}
}
core/src/main/java/jenkins/model/Jenkins.java
浏览文件 @
f85eb32b
...
@@ -58,7 +58,6 @@ import hudson.model.LoadBalancer;
...
@@ -58,7 +58,6 @@ import hudson.model.LoadBalancer;
import
hudson.model.ManagementLink
;
import
hudson.model.ManagementLink
;
import
hudson.model.ModifiableItemGroup
;
import
hudson.model.ModifiableItemGroup
;
import
hudson.model.NoFingerprintMatch
;
import
hudson.model.NoFingerprintMatch
;
import
hudson.model.Node.Mode
;
import
hudson.model.OverallLoadStatistics
;
import
hudson.model.OverallLoadStatistics
;
import
hudson.model.Project
;
import
hudson.model.Project
;
import
hudson.model.RestartListener
;
import
hudson.model.RestartListener
;
...
@@ -101,7 +100,6 @@ import hudson.Plugin;
...
@@ -101,7 +100,6 @@ import hudson.Plugin;
import
hudson.PluginManager
;
import
hudson.PluginManager
;
import
hudson.PluginWrapper
;
import
hudson.PluginWrapper
;
import
hudson.ProxyConfiguration
;
import
hudson.ProxyConfiguration
;
import
hudson.StructuredForm
;
import
hudson.TcpSlaveAgentListener
;
import
hudson.TcpSlaveAgentListener
;
import
hudson.UDPBroadcastThread
;
import
hudson.UDPBroadcastThread
;
import
hudson.Util
;
import
hudson.Util
;
...
@@ -1849,6 +1847,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
...
@@ -1849,6 +1847,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
public
void
setSecurityRealm
(
SecurityRealm
securityRealm
)
{
public
void
setSecurityRealm
(
SecurityRealm
securityRealm
)
{
if
(
securityRealm
==
null
)
if
(
securityRealm
==
null
)
securityRealm
=
SecurityRealm
.
NO_AUTHENTICATION
;
securityRealm
=
SecurityRealm
.
NO_AUTHENTICATION
;
this
.
useSecurity
=
true
;
this
.
securityRealm
=
securityRealm
;
this
.
securityRealm
=
securityRealm
;
// reset the filters and proxies for the new SecurityRealm
// reset the filters and proxies for the new SecurityRealm
try
{
try
{
...
@@ -1871,9 +1870,17 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
...
@@ -1871,9 +1870,17 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
public
void
setAuthorizationStrategy
(
AuthorizationStrategy
a
)
{
public
void
setAuthorizationStrategy
(
AuthorizationStrategy
a
)
{
if
(
a
==
null
)
if
(
a
==
null
)
a
=
AuthorizationStrategy
.
UNSECURED
;
a
=
AuthorizationStrategy
.
UNSECURED
;
useSecurity
=
true
;
authorizationStrategy
=
a
;
authorizationStrategy
=
a
;
}
}
public
void
disableSecurity
()
{
useSecurity
=
null
;
setSecurityRealm
(
SecurityRealm
.
NO_AUTHENTICATION
);
authorizationStrategy
=
AuthorizationStrategy
.
UNSECURED
;
markupFormatter
=
null
;
}
public
Lifecycle
getLifecycle
()
{
public
Lifecycle
getLifecycle
()
{
return
Lifecycle
.
get
();
return
Lifecycle
.
get
();
}
}
...
@@ -2422,27 +2429,6 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
...
@@ -2422,27 +2429,6 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
workspaceDir
=
json
.
getString
(
"rawWorkspaceDir"
);
workspaceDir
=
json
.
getString
(
"rawWorkspaceDir"
);
buildsDir
=
json
.
getString
(
"rawBuildsDir"
);
buildsDir
=
json
.
getString
(
"rawBuildsDir"
);
// keep using 'useSecurity' field as the main configuration setting
// until we get the new security implementation working
// useSecurity = null;
if
(
json
.
has
(
"use_security"
))
{
useSecurity
=
true
;
JSONObject
security
=
json
.
getJSONObject
(
"use_security"
);
setSecurityRealm
(
SecurityRealm
.
all
().
newInstanceFromRadioList
(
security
,
"realm"
));
setAuthorizationStrategy
(
AuthorizationStrategy
.
all
().
newInstanceFromRadioList
(
security
,
"authorization"
));
if
(
security
.
has
(
"markupFormatter"
))
{
markupFormatter
=
req
.
bindJSON
(
MarkupFormatter
.
class
,
security
.
getJSONObject
(
"markupFormatter"
));
}
else
{
markupFormatter
=
null
;
}
}
else
{
useSecurity
=
null
;
setSecurityRealm
(
SecurityRealm
.
NO_AUTHENTICATION
);
authorizationStrategy
=
AuthorizationStrategy
.
UNSECURED
;
markupFormatter
=
null
;
}
if
(
json
.
has
(
"viewsTabBar"
))
{
if
(
json
.
has
(
"viewsTabBar"
))
{
viewsTabBar
=
req
.
bindJSON
(
ViewsTabBar
.
class
,
json
.
getJSONObject
(
"viewsTabBar"
));
viewsTabBar
=
req
.
bindJSON
(
ViewsTabBar
.
class
,
json
.
getJSONObject
(
"viewsTabBar"
));
}
else
{
}
else
{
...
...
core/src/main/resources/hudson/security/GlobalSecurityConfiguration/config.groovy
0 → 100644
浏览文件 @
f85eb32b
package
hudson.security.csrf.GlobalCrumbIssuerConfiguration
import
hudson.security.SecurityRealm
import
hudson.security.AuthorizationStrategy
def
f
=
namespace
(
lib
.
FormTagLib
)
f
.
optionalBlock
(
field:
"useSecurity"
,
title:
_
(
"Enable security"
),
checked:
app
.
useSecurity
)
{
f
.
entry
(
title:
_
(
"TCP port for JNLP slave agents"
))
{
int
port
=
app
.
slaveAgentPort
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"fixed"
,
id:
"sat.fixed"
,
chcked:
port
>
0
,
onclick:
"\$('sat.port').disabled=false"
)
label
(
"for"
:
"sat.fixed"
,
_$
(
"Fixed"
))
text
(
" : "
)
input
(
type:
"text"
,
"class"
:
"number"
,
name:
"slaveAgentPort"
,
id:
"sat.port"
,
value:
port
>
0
?
port
:
null
,
disabled:
port
>
0
?
null
:
"true"
)
raw
(
" "
)
////////////////////////////
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"random"
,
id:
"sat.random"
,
checked:
port
==
0
,
onclick:
"\$('sat.port').disabled=true"
)
label
(
"for"
:
"sat.random"
,
_$
(
"Random"
))
raw
(
" "
)
////////////////////////////
f
.
radio
(
name:
"slaveAgentPortType"
,
value:
"disable"
,
id:
"sat.disabled"
,
checked:
port
==-
1
,
onclick:
"\$('sat.port').disabled=true"
)
label
(
"for"
:
"sat.random"
,
_$
(
"Random"
))
// checked="${it.useSecurity}" help="/help/system-config/enableSecurity.html">
// help="/help/system-config/master-slave/slave-agent-port.html">
/*
<input type="text" class="number" name="slaveAgentPort" id="sat.port"
value="${it.slaveAgentPort gt 0 ? it.slaveAgentPort : null}"
disabled="${it.slaveAgentPort gt 0 ? null : 'true'}"/>
<st:nbsp />
<f:radio name="slaveAgentPortType" value="random" id="sat.random"
checked="${it.slaveAgentPort==0}" onclick="$('sat.port').disabled=true" />
<label for="sat.random">${%Random}</label>
<st:nbsp />
<f:radio name="slaveAgentPortType" value="disable" id="sat.disabled"
checked="${it.slaveAgentPort==-1}" onclick="$('sat.port').disabled=true" />
<label for="sat.disabled">${%Disable}</label>
</f:entry>
*/
}
f
.
dropdownDescriptorSelector
(
title:
_
(
"Markup Formatter"
),
field:
"markupFormatter"
)
f
.
entry
(
title:
_
(
"Access Control"
))
{
table
(
style:
"width:100%"
)
{
f
.
descriptorRadioList
(
title:
_
(
"Security Realm"
),
varName:
"realm"
,
instance:
app
.
securityRealm
,
descriptors:
SecurityRealm
.
all
())
f
.
descriptorRadioList
(
title:
_
(
"Authorization"
),
varName:
"authorization"
,
instance:
app
.
authorizationStrategy
,
descriptors:
AuthorizationStrategy
.
all
())
}
}
}
/*
<f:dropdownDescriptorSelector title="${%Markup Formatter}" field="markupFormatter" />
<f:entry title="${%Access Control}">
<table style="width:100%">
<f:descriptorRadioList title="${%Security Realm}" varName="realm"
instance="${it.securityRealm}"
descriptors="${h.securityRealmDescriptors}"/>
<f:descriptorRadioList title="${%Authorization}" varName="authorization"
instance="${it.authorizationStrategy}"
descriptors="${h.authorizationStrategyDescriptors}"/>
</table>
</f:entry>
</f:optionalBlock>
*/
\ No newline at end of file
core/src/main/resources/jenkins/model/Jenkins/configure.jelly
浏览文件 @
f85eb32b
...
@@ -106,44 +106,6 @@ THE SOFTWARE.
...
@@ -106,44 +106,6 @@ THE SOFTWARE.
</f:entry>
</f:entry>
</j:if>
</j:if>
<f:optionalBlock name="use_security" title="${%Enable security}"
checked="${it.useSecurity}" help="/help/system-config/enableSecurity.html">
<f:entry title="${%TCP port for JNLP slave agents}"
help="/help/system-config/master-slave/slave-agent-port.html">
<f:radio name="slaveAgentPortType" value="fixed" id="sat.fixed"
checked="${it.slaveAgentPort gt 0}" onclick="$('sat.port').disabled=false"/>
<label for="sat.fixed">${%Fixed}</label> :
<input type="text" class="number" name="slaveAgentPort" id="sat.port"
value="${it.slaveAgentPort gt 0 ? it.slaveAgentPort : null}"
disabled="${it.slaveAgentPort gt 0 ? null : 'true'}"/>
<st:nbsp />
<f:radio name="slaveAgentPortType" value="random" id="sat.random"
checked="${it.slaveAgentPort==0}" onclick="$('sat.port').disabled=true" />
<label for="sat.random">${%Random}</label>
<st:nbsp />
<f:radio name="slaveAgentPortType" value="disable" id="sat.disabled"
checked="${it.slaveAgentPort==-1}" onclick="$('sat.port').disabled=true" />
<label for="sat.disabled">${%Disable}</label>
</f:entry>
<f:dropdownDescriptorSelector title="${%Markup Formatter}" field="markupFormatter" />
<f:entry title="${%Access Control}">
<table style="width:100%">
<f:descriptorRadioList title="${%Security Realm}" varName="realm"
instance="${it.securityRealm}"
descriptors="${h.securityRealmDescriptors}"/>
<f:descriptorRadioList title="${%Authorization}" varName="authorization"
instance="${it.authorizationStrategy}"
descriptors="${h.authorizationStrategyDescriptors}"/>
</table>
</f:entry>
</f:optionalBlock>
<!-- global configuration from everyone -->
<!-- global configuration from everyone -->
<j:forEach var="descriptor" items="${h.getSortedDescriptorsForGlobalConfig()}">
<j:forEach var="descriptor" items="${h.getSortedDescriptorsForGlobalConfig()}">
<j:set var="instance" value="${descriptor}" /><!-- this makes the <f:textbox field=.../> work -->
<j:set var="instance" value="${descriptor}" /><!-- this makes the <f:textbox field=.../> work -->
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录