34. Run-As Authentication Replacement
34. Run-As Authentication Replacement
34.1 Overview
The AbstractSecurityInterceptor is able to temporarily replace the Authentication object in the SecurityContext and SecurityContextHolder during the secure object callback phase.
AbstractSecurityInterceptor
は、セキュアオブジェクトが呼び出されているフェーズの間、 SecurityContext
と SecurityContextHolder
の中にある Authentication
オブジェクトを一時的に置き換えることができます。
This only occurs if the original Authentication object was successfully processed by the AuthenticationManager and AccessDecisionManager.
これは、オリジナルの Authentication
オブジェクトが AuthenticationManager
と AccessDecisionManager
によって成功裏に処理されている場合にだけ発生します。
The RunAsManager will indicate the replacement Authentication object, if any, that should be used during the SecurityInterceptorCallback.
RunAsManager
は SecurityInterceptorCallback
の間に使用されるべき Authentication
オブジェクトを示します。
By temporarily replacing the Authentication object during the secure object callback phase, the secured invocation will be able to call other objects which require different authentication and authorization credentials.
セキュアオブジェクトの呼び出しフェーズの間に使用される一時的に置き換えられた Authentication
オブジェクトによって、保護された実行は他の認証と認可を必要とする他のオブジェクトを呼ぶことができます。
It will also be able to perform any internal security checks for specific GrantedAuthority objects.
それは、指定された GrantedAuthority
オブジェクトのための任意の内部セキュリティチェックも行うことができるでしょう。
Because Spring Security provides a number of helper classes that automatically configure remoting protocols based on the contents of the SecurityContextHolder, these run-as replacements are particularly useful when calling remote web services.
なぜなら、 Spring Security は SecurityContextHolder
の内容をベースにした遠隔プロトコルを自動で設定する多くのヘルパークラスを提供しています。
run-as 置き換えは、遠隔の Web サービスを呼び出すときに特に便利です。
34.2 Configuration
A RunAsManager interface is provided by Spring Security:
RunAsManager
インターフェースは Spring Security によって提供されています。
Authentication buildRunAs(Authentication authentication, Object object, List<ConfigAttribute> config); boolean supports(ConfigAttribute attribute); boolean supports(Class clazz);
The first method returns the Authentication object that should replace the existing Authentication object for the duration of the method invocation.
最初のメソッドは、既存の Authentication
オブジェクトをメソッド実行の間だけ置き換えるための Authentication
オブジェクトを返します。
If the method returns null, it indicates no replacement should be made.
もしメソッドが null を返す場合、置き換えが不要であることを示します。
The second method is used by the AbstractSecurityInterceptor as part of its startup validation of configuration attributes.
2つ目のメソッドは、 AbstractSecurityInterceptor
によって起動時の configuration attributes の検証の一部として使用されます。
The supports(Class) method is called by a security interceptor implementation to ensure the configured RunAsManager supports the type of secure object that the security interceptor will present.
supports(Class)
メソッドはセキュリティインターセプターの実装によって、セキュアインターセプターが提供したセキュアオブジェクトの型を、設定された RunAsManager
がサポートすることを確実にするために実行されます。
One concrete implementation of a RunAsManager is provided with Spring Security.
1つの RunAsManager
の実装クラスが Spring Security によって提供されています。
The RunAsManagerImpl class returns a replacement RunAsUserToken if any ConfigAttribute starts with RUN_AS_.
RunAsManagerImpl
クラスは、もし任意の ConfigAttribute
が RUN_AS_
で始まる場合に、置き換えられた RunAsUserToken
を返します。
If any such ConfigAttribute is found, the replacement RunAsUserToken will contain the same principal, credentials and granted authorities as the original Authentication object, along with a new GrantedAuthorityImpl for each RUN_AS_ ConfigAttribute.
もしそのような ConfigAttribute
が見つかった場合、置き換えられた RunAsUserToken
は、オリジナルの Authentication
オブジェクトと同じプリンシパル、資格情報、そして与えられた権限と、個々の ConfigAttribute
で設定された RUN_AS_
による新しい GrantedAuthorityImpl
を含みます。
Each new GrantedAuthorityImpl will be prefixed with ROLE_, followed by the RUN_AS ConfigAttribute.
それぞれの GrantedAuthorityImpl
は前に ROLE_
が付き、後ろに RUN_AS ConfigAttribute
による設定が続きます
For example, a RUN_AS_SERVER will result in the replacement RunAsUserToken containing a ROLE_RUN_AS_SERVER granted authority.
例えば、 RUN_AS_SERVER
は RunAsUserToken
に置き換えられると、 ROLE_RUN_AS_SERVER
が設定されます。
The replacement RunAsUserToken is just like any other Authentication object.
置き換えられた RunAsUserToken
は、ちょうどその他の Authentication
オブジェクトのようなものです。
It needs to be authenticated by the AuthenticationManager, probably via delegation to a suitable AuthenticationProvider.
それは、適切な AuthenticationProvider
に委譲し、 AuthenticationManager
によって認証されている必要があります。
The RunAsImplAuthenticationProvider performs such authentication.
RunAsImplAuthenticationProvider
は、そのような認証を行います。
It simply accepts as valid any RunAsUserToken presented.
それは単純に任意の提供された RunAsUserToken
を有効として許可します。
To ensure malicious code does not create a RunAsUserToken and present it for guaranteed acceptance by the RunAsImplAuthenticationProvider, the hash of a key is stored in all generated tokens.
悪意のあるコードが RunAsUserToken
を作成せず、 RunAsImplAuthenticationProvider
によって確実に受け入れられるようにするために、生成されたすべてのトークンにキーのハッシュが格納されます。
The RunAsManagerImpl and RunAsImplAuthenticationProvider is created in the bean context with the same key:
RunAsManagerImpl
と RunAsImplAuthenticationProvider
は同じキーでコンテキストの Bean として作られます。
<bean id="runAsManager" class="org.springframework.security.access.intercept.RunAsManagerImpl"> <property name="key" value="my_run_as_password"/> </bean> <bean id="runAsAuthenticationProvider" class="org.springframework.security.access.intercept.RunAsImplAuthenticationProvider"> <property name="key" value="my_run_as_password"/> </bean>
By using the same key, each RunAsUserToken can be validated it was created by an approved RunAsManagerImpl.
同じキーを使うことで、それぞれの RunAsUserToken
は許可された RunAsManagerImpl
によって作られたことを検証できます。
The RunAsUserToken is immutable after creation for security reasons
RunAsUserToken
はセキュリティのため作られた後は変更できません。