1

https://wiki.eclipse.org/Scout/Concepts/Securityにあるスカウトのデフォルトのセキュリティ概念に基づく認証が必要です。

私がやったこと:

BasicSecurityFilterサーバーに追加しましたplugin.xml

<extension name="" point="org.eclipse.scout.rt.server.commons.filters">
      <filter aliases="/ /process /remotefiles /updatesite" class="org.eclipse.scout.http.servletfilter.security.BasicSecurityFilter" ranking="30"></filter>
</extension>

そして、それを有効にしましたconfig.ini

org.eclipse.scout.http.servletfilter.security.BasicSecurityFilter#active=true
org.eclipse.scout.http.servletfilter.security.BasicSecurityFilter#realm=Development
org.eclipse.scout.http.servletfilter.security.BasicSecurityFilter#users=TEST\=admin

クライアント側では、次のように追加しInternalNetAuthenticatorましたplugin.xml:

<extension point="org.eclipse.core.net.authenticator">
    <authenticator class="org.eclipse.scout.rt.ui.rap.login.internal.InternalNetAuthenticator"</authenticator>
</extension>

クライアントでデフォルトのオーセンティケータとして設定しますActivator:

@Override
public void start(BundleContext context) throws Exception {
  super.start(context);
  plugin = this;
  InternalNetAuthenticator authenticator = new InternalNetAuthenticator();
  InternalNetAuthenticator.setDefault(authenticator);
}

何が起こるのですか:

  • BasicSecurityFilter.negotiate()アプリケーションにアクセスするときに呼び出されます (最初のロード、例http://localhost:8015/web)
  • InternalNetAuthenticator.getPasswordAuthentication()のネゴシエーションがBasicSecurityFilter失敗したときに呼び出されます (これは、ユーザーとパスワードが HTTP ヘッダーで見つからないか、ユーザーとパスワードが無効な場合です)。
    • InternalNetAuthenticator.showModalDialog(status, display)Display.getDefault() または Display.getCurrent() は常に を返すため、RAP レベル ( を参照) でダイアログを開くことはできませんnull
      • これは、すべての UI 操作 (ダイアログを開くなど) が UIThread に表示されなければならないためです ( の java-doc を参照Display.getDefault())。
      • はUIThreadInternalNetAuthenticatorインスタンス化されますが (「 」を参照Activator.start())、 UIThread では呼び出されません! どうして???
    • オブジェクトを返すとPasswordAuthentication、HTTP ヘッダー内の資格情報が次のBasicSecurityFilter.negotiate()呼び出しに提供されます。
  • BasicSecurityFilter.negotiate()指定された資格情報で再度呼び出されます。

失敗するもの:

InternalNetAuthenticator.showModalDialog(status, display)が UI スレッドで呼び出されないため、次のようになりますNullPointerException

java.lang.NullPointerException
    at org.eclipse.scout.rt.ui.rap.login.internal.InternalNetAuthenticator.showModalDialog(InternalNetAuthenticator.java:102)
...

私がすでに検討したこと:

  • 一般情報
    • https://wiki.eclipse.org/Scout/HowTo/3.9/Extending_the_login_dialog
    • https://wiki.eclipse.org/Scout/Concepts/Securit
  • UI スレッドの問題
    • https://www.eclipse.org/forums/index.php/t/440290/
    • https://www.eclipse.org/rap/developers-guide/devguide.php?topic=threads.html
    • Activator.start()独自のオーセンティケーターを作成し、次のようにコンストラクターにパラメーターを追加することにより 、メソッドでオーセンティケーターをインスタンス化するときに、既に UI スレッドを格納しようとしました。
      • MyAuthenticator my_authenticator = new MyAuthenticator(Thread.currentThread());
      • しかし、これはIllegelStateExceptionまたはそのようなものを引き起こします。したがって、この方法では UI スレッドにアクセスできません。
    • BasicSecurityFilterRAP レベル ( plugin.xmlRAP バンドル内) を使用すると、システムのデフォルトのログイン ダイアログを使用できるようになります 。
      • しかし、他のサーバー側システムにアクセスできるカスタム SecurityFilter が必要なため、サーバー側に表示する必要があり、RAP/クライアント側の SecurityFilter はオプションではありません!

概要

私が見ることができるのは、UIスレッドで問題を解決することが、この問題を前進させるための好ましい方法であることです.

eclipse-scout-RAP 環境でカスタム ログイン ダイアログを表示する代替ソリューションも受け入れます。

4

1 に答える 1

1

問題の説明:

あなたのユースケースを正しく理解していれば、フォームベースの認証のようなものを導入したいと考えています。これは、RAP UI スレッドでログイン ダイアログを表示することで達成したかったことだと思います。

解決策の提案:

[1] にある Scout デモ アプリケーション BahBah チャットにフォーム ベースの認証を導入するために、いくつかの手順が実行されました。この例は古い Scout バージョン (3.10) に基づいていることに注意してください。以下の説明では、[1] の実装が参照されます。

[1] では、Tomcat Web コンテナの機能を利用してフォームベースの認証を実現するというアプローチが取られました。サンプルの HTML ログイン ページ [2] は、web-resources フォルダーの下の RAP UI バンドルにあります。そのため、RAP アプリケーションの plugin.xml [3] では、サーブレット フィルタ BasicForwardSecurityFilter が削除されました。/res などの Web リソースにアクセスできることを確認します。

<extension point="org.eclipse.equinox.http.registry.resources">
  <resource alias="/res" base-name="/web-resources"/>
</extension>

RAP アプリケーションの web.xml ファイルで、次のエントリが作成されました。

<!-- Activate form-based authentication -->
<login-config>
  <auth-method>FORM</auth-method>
  <realm-name>BahBahJAASLogin</realm-name>
  <form-login-config>
    <form-login-page>/res/index.html</form-login-page>
    <form-error-page>/res/index.html</form-error-page>
  </form-login-config>
</login-config>

<!-- Define security role to access the application -->
<security-role>
  <role-name>BahBahRolePrincipal</role-name>
</security-role>

<!-- static resources under /res/* should be accessible without requiring authentication --> 
<security-constraint>
  <web-resource-collection>
    <web-resource-name>All Access</web-resource-name>
    <url-pattern>/res/*</url-pattern>
    <http-method>DELETE</http-method>
    <http-method>PUT</http-method>
    <http-method>HEAD</http-method>
    <http-method>OPTIONS</http-method>
    <http-method>TRACE</http-method>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
  </web-resource-collection>
  <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>

<!-- Protect all other URLs of the application -->
<security-constraint>
  <web-resource-collection>
    <web-resource-name>Protected Resources</web-resource-name
    <url-pattern>/web/*</url-pattern>
    <url-pattern>/tablet/*</url-pattern>
    <url-pattern>/mobile/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
  </web-resource-collection>
  <auth-constraint>
    <role-name>BahBahRolePrincipal</role-name>
  </auth-constraint>
  <user-data-constraint>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>

<!-- Define security filter and mapping --> 
<filter>
  <filter-name>BahbahSecurityFilter</filter-name>
  <filter-class>com.bsiag.securityfilter.BahbahSecurityFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>BahbahSecurityFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

BahbahSecurityFilter は、認証されたプリンシパルのみが UI サーバー上の保護されたリソースにアクセスできるようにします。doFilter メソッドでは、次のようなメソッドを呼び出してチェックを行います。

// Taken from org.eclipse.scout.rt.server.commons.authentication.ServletFilterHelper#isRunningWithValidSubject(HttpServletRequest) see [4]
public boolean isRunningWithValidSubject(HttpServletRequest req) {
  String username = req.getRemoteUser();
  if (username == null || username.isEmpty()) {
    return false;
  }

  Subject subject = Subject.getSubject(AccessController.getContext());
  if (subject == null || subject.getPrincipals().isEmpty()) {
    return false;
  }

  for (Principal principal : subject.getPrincipals()) {
    if (username.equalsIgnoreCase(principal.getName())) {
      return true;
    }
  }
  return false;
}

BahBahChat では、レルム [5] とログイン モジュールが構成され、ユーザーを認証します。具体的には、UserPrincipal と RolePrincipal が定義され、LoginModule クラスも作成されます。

Tomcat context.xml ファイルで、レルムが構成されます。

<Realm className="org.apache.catalina.realm.JAASRealm"
       appName="BahBahJAASLogin"
       userClassNames="com.bsiag.securityfilter.BahBahUserPrincipal"
       roleClassNames="com.bsiag.securityfilter.BahBahRolePrincipal"/>

最後に、jaas.config ファイルが定義されます。

BahBahJAASLogin  {
  com.bsiag.securityfilter.BahBahJAASLoginModule required debug=true;
};

BahBahJAASLoginModule は、実際の認証プロセスを実装します。Tomcat で JAAS 認証を設定する良い例は、[6] にあります。

必要な手順をより一般的な方法でまとめた Eclipse Scout フォーラムの投稿 [7] も参照してください。

于 2016-01-18T11:13:14.990 に答える