SEC-1013: Refactored out use of ConfigAttributeDefinition from remaining interfaces
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
or web requests. A pre-invocation decision on whether the invocation is allowed to proceed is made by
|
||||
the <interfacename>AccessDecisionManager</interfacename>.
|
||||
</para>
|
||||
|
||||
|
||||
<section>
|
||||
<title>The AccessDecisionManager</title>
|
||||
<para>The <interfacename>AccessDecisionManager</interfacename> is called by the
|
||||
@@ -70,7 +70,7 @@
|
||||
<interfacename>AccessDecisionManager</interfacename> interface contains three
|
||||
methods:
|
||||
<programlisting>
|
||||
void decide(Authentication authentication, Object secureObject, ConfigAttributeDefinition config) throws AccessDeniedException;
|
||||
void decide(Authentication authentication, Object secureObject, List<ConfigAttribute> config) throws AccessDeniedException;
|
||||
boolean supports(ConfigAttribute attribute);
|
||||
boolean supports(Class clazz);
|
||||
</programlisting>
|
||||
@@ -124,7 +124,7 @@
|
||||
<para>The <interfacename>AccessDecisionVoter</interfacename> interface has three
|
||||
methods:
|
||||
<programlisting>
|
||||
int vote(Authentication authentication, Object object, ConfigAttributeDefinition config);
|
||||
int vote(Authentication authentication, Object object, List<ConfigAttribute> config);
|
||||
boolean supports(ConfigAttribute attribute);
|
||||
boolean supports(Class clazz);
|
||||
</programlisting>
|
||||
@@ -168,9 +168,9 @@ boolean supports(Class clazz);
|
||||
<para>
|
||||
The most commonly used <interfacename>AccessDecisionVoter</interfacename>
|
||||
provided with Spring Security is the simple <classname>RoleVoter</classname>, which treats
|
||||
configuration attributes as simple role names and votes to grant access if the user has been assigned
|
||||
configuration attributes as simple role names and votes to grant access if the user has been assigned
|
||||
that role.</para>
|
||||
<para>It will vote if any ConfigAttribute begins with the prefix <literal>ROLE_</literal>.
|
||||
<para>It will vote if any ConfigAttribute begins with the prefix <literal>ROLE_</literal>.
|
||||
It will vote to grant access if there is a <interfacename>GrantedAuthority</interfacename> which returns a
|
||||
<literal>String</literal> representation (via the
|
||||
<literal>getAuthority()</literal> method) exactly equal to one or more
|
||||
@@ -183,8 +183,8 @@ boolean supports(Class clazz);
|
||||
<literal>RoleVoter</literal> is case sensitive on comparisons as well
|
||||
as the <literal>ROLE_</literal> prefix.</para>
|
||||
</section>
|
||||
|
||||
<!--
|
||||
|
||||
<!--
|
||||
|
||||
<para><literal>BasicAclEntryVoter</literal> is the other concrete
|
||||
voter included with Spring Security. It integrates with Spring
|
||||
@@ -206,7 +206,7 @@ boolean supports(Class clazz);
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="aclContactDeleteVoter"
|
||||
<bean id="aclContactDeleteVoter"
|
||||
class="org.springframework.security.vote.BasicAclEntryVoter">
|
||||
<property name="processConfigAttribute" value="ACL_CONTACT_DELETE"/>
|
||||
<property name="processDomainObjectClass" value="sample.contact.Contact"/>
|
||||
@@ -248,7 +248,7 @@ boolean supports(Class clazz);
|
||||
deprecated, and have all references to the replacement package limited
|
||||
to the chapter describing the new ACL implementation.</para>
|
||||
-->
|
||||
|
||||
|
||||
<section>
|
||||
<title>Custom Voters</title>
|
||||
<para>It is also possible to implement a custom
|
||||
@@ -288,7 +288,7 @@ boolean supports(Class clazz);
|
||||
<para><xref linkend="authz-after-invocation"/> illustrates Spring Security's
|
||||
<literal>AfterInvocationManager</literal> and its concrete
|
||||
implementations.
|
||||
|
||||
|
||||
<figure xml:id="authz-after-invocation">
|
||||
<title>After Invocation Implementation</title>
|
||||
<mediaobject>
|
||||
@@ -299,7 +299,7 @@ boolean supports(Class clazz);
|
||||
<imagedata align="center" fileref="images/AfterInvocation.gif" format="GIF"/>
|
||||
</imageobject>
|
||||
</mediaobject>
|
||||
|
||||
|
||||
</figure>
|
||||
</para>
|
||||
|
||||
@@ -455,7 +455,7 @@ boolean supports(Class clazz);
|
||||
<ref local="org.springframework.security.acl.basic.SimpleAclEntry.READ"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</bean>
|
||||
]]> </programlisting></para>
|
||||
|
||||
<para>In the above example, the <literal>Contact</literal> will be
|
||||
@@ -486,7 +486,7 @@ boolean supports(Class clazz);
|
||||
<ref local="org.springframework.security.acl.basic.SimpleAclEntry.READ"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</bean>
|
||||
]]></programlisting>
|
||||
As you can imagine, the returned <literal>Object</literal>
|
||||
must be a <literal>Collection</literal> or array for this provider
|
||||
@@ -501,7 +501,7 @@ boolean supports(Class clazz);
|
||||
</section>
|
||||
|
||||
<section xml:id="authorization-taglibs"><info><title>Authorization Tag Libraries</title></info>
|
||||
|
||||
|
||||
|
||||
<para><literal>AuthorizeTag</literal> is used to include content if
|
||||
the current principal holds certain
|
||||
@@ -592,4 +592,4 @@ boolean supports(Class clazz);
|
||||
works exactly the samae as
|
||||
<literal>AccessControlListTag</literal>.</para>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<chapter xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="runas"><info><title>Run-As Authentication Replacement</title></info>
|
||||
|
||||
|
||||
|
||||
|
||||
<section xml:id="runas-overview">
|
||||
<info><title>Overview</title></info>
|
||||
|
||||
|
||||
<para>The <classname>AbstractSecurityInterceptor</classname> is able to
|
||||
temporarily replace the <interfacename>Authentication</interfacename> object in
|
||||
the <interfacename>SecurityContext</interfacename> and
|
||||
@@ -15,7 +15,7 @@
|
||||
<literal>RunAsManager</literal> will indicate the replacement
|
||||
<interfacename>Authentication</interfacename> object, if any, that should be used
|
||||
during the <literal>SecurityInterceptorCallback</literal>.</para>
|
||||
|
||||
|
||||
<para>By temporarily replacing the <interfacename>Authentication</interfacename>
|
||||
object during the secure object callback phase, the secured invocation
|
||||
will be able to call other objects which require different
|
||||
@@ -27,17 +27,17 @@
|
||||
<classname>SecurityContextHolder</classname>, these run-as replacements
|
||||
are particularly useful when calling remote web services</para>
|
||||
</section>
|
||||
|
||||
|
||||
<section xml:id="runas-config">
|
||||
<info><title>Configuration</title></info>
|
||||
<para>A <literal>RunAsManager</literal> interface is provided by Spring Security:
|
||||
<programlisting>
|
||||
Authentication buildRunAs(Authentication authentication, Object object, ConfigAttributeDefinition config);
|
||||
Authentication buildRunAs(Authentication authentication, Object object, List<ConfigAttribute> config);
|
||||
boolean supports(ConfigAttribute attribute);
|
||||
boolean supports(Class clazz);
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
|
||||
<para>The first method returns the <interfacename>Authentication</interfacename>
|
||||
object that should replace the existing
|
||||
<interfacename>Authentication</interfacename> object for the duration of the
|
||||
@@ -49,7 +49,7 @@
|
||||
interceptor implementation to ensure the configured
|
||||
<literal>RunAsManager</literal> supports the type of secure object
|
||||
that the security interceptor will present.</para>
|
||||
|
||||
|
||||
<para>One concrete implementation of a <literal>RunAsManager</literal>
|
||||
is provided with Spring Security. The
|
||||
<literal>RunAsManagerImpl</literal> class returns a replacement
|
||||
@@ -68,7 +68,7 @@
|
||||
<literal>RUN_AS_SERVER</literal> will result in the replacement
|
||||
<literal>RunAsUserToken</literal> containing a
|
||||
<literal>ROLE_RUN_AS_SERVER</literal> granted authority.</para>
|
||||
|
||||
|
||||
<para>The replacement <literal>RunAsUserToken</literal> is just like
|
||||
any other <interfacename>Authentication</interfacename> object. It needs to be
|
||||
authenticated by the <interfacename>AuthenticationManager</interfacename>,
|
||||
@@ -77,7 +77,7 @@
|
||||
<literal>RunAsImplAuthenticationProvider</literal> performs such
|
||||
authentication. It simply accepts as valid any
|
||||
<literal>RunAsUserToken</literal> presented.</para>
|
||||
|
||||
|
||||
<para>To ensure malicious code does not create a
|
||||
<literal>RunAsUserToken</literal> and present it for guaranteed
|
||||
acceptance by the <literal>RunAsImplAuthenticationProvider</literal>,
|
||||
@@ -101,4 +101,4 @@
|
||||
<literal>RunAsUserToken</literal> is immutable after creation for
|
||||
security reasons</para>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
@@ -5,32 +5,32 @@
|
||||
<info>
|
||||
<title>AOP Alliance (MethodInvocation) Security Interceptor</title>
|
||||
</info>
|
||||
|
||||
|
||||
<para>
|
||||
Prior to Spring Security 2.0, securing <classname>MethodInvocation</classname>s needed quite a
|
||||
lot of boiler plate configuration. Now the recommended approach for method security
|
||||
Prior to Spring Security 2.0, securing <classname>MethodInvocation</classname>s needed quite a
|
||||
lot of boiler plate configuration. Now the recommended approach for method security
|
||||
is to use <link xlink:href="#ns-method-security">namespace configuration</link>.
|
||||
This way the method security infrastructure beans are configured automatically for you so you don't really need to
|
||||
This way the method security infrastructure beans are configured automatically for you so you don't really need to
|
||||
know about the implementation classes. We'll just provide a quick overview of the classes that are involved here.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Method security in enforced using a <classname>MethodSecurityInterceptor</classname>, which secures
|
||||
<classname>MethodInvocation</classname>s. Depending on the configuration approach, an interceptor may be specific to a single
|
||||
<classname>MethodInvocation</classname>s. Depending on the configuration approach, an interceptor may be specific to a single
|
||||
bean or shared between multiple beans. The interceptor uses a <interfacename>MethodDefinitionSource</interfacename>
|
||||
instance to obtain the configuration attributes that apply to a particular method invocation.
|
||||
<classname>MapBasedMethodDefinitionSource</classname> is used to store configuration attributes keyed by method names
|
||||
instance to obtain the configuration attributes that apply to a particular method invocation.
|
||||
<classname>MapBasedMethodDefinitionSource</classname> is used to store configuration attributes keyed by method names
|
||||
(which can be wildcarded) and will be used internally when the attributes are defined in the application context using
|
||||
the <literal><intercept-methods></literal> or <literal><protect-point></literal> elements. Other implementations
|
||||
will be used to handle annotation-based configuration.
|
||||
</para>
|
||||
|
||||
|
||||
<section>
|
||||
<title>Explicit MethodSecurityIterceptor Configuration</title>
|
||||
<para>
|
||||
You can of course configure a <classname>MethodSecurityIterceptor</classname> directly in your application context
|
||||
for use with one of Spring AOP's proxying mechanisms:
|
||||
<programlisting><![CDATA[
|
||||
<programlisting><![CDATA[
|
||||
<bean id="bankManagerSecurity"
|
||||
class="org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor">
|
||||
<property name="authenticationManager" ref="authenticationManager"/>
|
||||
@@ -42,7 +42,7 @@
|
||||
org.springframework.security.context.BankManager.getBalance=ROLE_TELLER,ROLE_SUPERVISOR
|
||||
</value>
|
||||
</property>
|
||||
</bean> ]]>
|
||||
</bean> ]]>
|
||||
</programlisting>
|
||||
</para>
|
||||
</section>
|
||||
@@ -119,15 +119,15 @@ pointcut domainObjectInstanceExecution(): target(PersistableEntity)
|
||||
|
||||
Object around(): domainObjectInstanceExecution() {
|
||||
if (this.securityInterceptor == null) {
|
||||
return proceed();
|
||||
return proceed();
|
||||
}
|
||||
|
||||
|
||||
AspectJCallback callback = new AspectJCallback() {
|
||||
public Object proceedWithObject() {
|
||||
return proceed();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return this.securityInterceptor.invoke(thisJoinPoint, callback);
|
||||
}
|
||||
|
||||
@@ -178,13 +178,13 @@ public void afterPropertiesSet() throws Exception {
|
||||
<info><title>FilterInvocation Security Interceptor</title></info>
|
||||
|
||||
<para>To secure <classname>FilterInvocation</classname>s, developers need
|
||||
to add a <classname>FilterSecurityInterceptor</classname> to their filter chain.
|
||||
to add a <classname>FilterSecurityInterceptor</classname> to their filter chain.
|
||||
A typical configuration example is provided below:</para>
|
||||
|
||||
<para>In the application context you will need to configure three
|
||||
beans:</para>
|
||||
|
||||
<programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<bean id="exceptionTranslationFilter"
|
||||
class="org.springframework.security.ui.ExceptionTranslationFilter">
|
||||
@@ -204,8 +204,8 @@ public void afterPropertiesSet() throws Exception {
|
||||
<property name="objectDefinitionSource">
|
||||
<security:filter-invocation-definition-source>
|
||||
<security:intercept-url pattern="/secure/super/**" access="ROLE_WE_DONT_HAVE"/>
|
||||
<security:intercept-url pattern="/secure/**" access="ROLE_SUPERVISOR,ROLE_TELLER"/>
|
||||
</security:filter-invocation-definition-source>
|
||||
<security:intercept-url pattern="/secure/**" access="ROLE_SUPERVISOR,ROLE_TELLER"/>
|
||||
</security:filter-invocation-definition-source>
|
||||
</property>
|
||||
</bean>]]> </programlisting>
|
||||
|
||||
@@ -245,7 +245,7 @@ public void afterPropertiesSet() throws Exception {
|
||||
Level Design section of this document.</para>
|
||||
|
||||
<para>The <classname>FilterSecurityInterceptor</classname> can be
|
||||
configured with configuration attributes in two ways. The first,
|
||||
configured with configuration attributes in two ways. The first,
|
||||
which is shown above, is using the <literal><filter-invocation-definition-source></literal>
|
||||
namespace element. This is similar to the <literal><filter-chain-map></literal>
|
||||
used to configure a <classname>FilterChainProxy</classname> but the <literal><intercept-url></literal>
|
||||
@@ -254,7 +254,7 @@ public void afterPropertiesSet() throws Exception {
|
||||
<interfacename>ObjectDefinitionSource</interfacename>, although this is beyond the
|
||||
scope of this document. Irrespective of the approach used, the
|
||||
<interfacename>ObjectDefinitionSource</interfacename> is responsible for returning
|
||||
a <literal>ConfigAttributeDefinition</literal> object that contains
|
||||
a <literal>List<ConfigAttribute></literal> containing
|
||||
all of the configuration attributes associated with a single secure
|
||||
HTTP URL.</para>
|
||||
|
||||
@@ -271,7 +271,7 @@ public void afterPropertiesSet() throws Exception {
|
||||
little relevance to most users of the
|
||||
<classname>FilterSecurityInterceptor</classname>.</para>
|
||||
|
||||
<para>When using the namespace option to configure the interceptor,
|
||||
<para>When using the namespace option to configure the interceptor,
|
||||
commas are used to delimit the different configuration
|
||||
attributes that apply to each HTTP URL. Each configuration attribute
|
||||
is assigned into its own <literal>SecurityConfig</literal> object. The
|
||||
@@ -299,7 +299,7 @@ public void afterPropertiesSet() throws Exception {
|
||||
<security:filter-invocation-definition-source path-type="regex">
|
||||
<security:intercept-url pattern="\A/secure/super/.*\Z" access="ROLE_WE_DONT_HAVE"/>
|
||||
<security:intercept-url pattern="\A/secure/.*\" access="ROLE_SUPERVISOR,ROLE_TELLER"/>
|
||||
</security:filter-invocation-definition-source>
|
||||
</security:filter-invocation-definition-source>
|
||||
</property>
|
||||
</bean>]]> </programlisting>
|
||||
|
||||
@@ -324,4 +324,4 @@ public void afterPropertiesSet() throws Exception {
|
||||
<literal>RunAsManager</literal>. If neither of these can process a
|
||||
given configuration attribute, an exception is thrown.</para>
|
||||
</section>
|
||||
</chapter>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user