舞台裏

Qiita が表でこっちが裏。こっそりやっていく。

SpringSecurity

ACL の記事書き始めた

とりあえず最小構成の Hello World を書いて動かした。 問題なさそうなので Hello World として記事に書き始めた。

ACL だいたい理解してきた

ACL がだいたい分かってきたので、記事の内容をあらためて考えてる。 しかし、分かりやすくするにはどういう順番で説明していくのがいいか結構悩む。

ACL のクラス間の関係を整理した

AclService LookupStrategy AclCache AclAuthorizationStrategy PermissionGrantingStratgy このあたりの関係をクラス図に起こしてみて、クラス間の関係を整理した。 だいたい役割とかが見えてきた。 どーん

ACL で必要になるクラスたちの役割について調査

ACL を実現するときに Bean を大量に登録しなければならないが、それぞれの役割が謎すぎてコンストラクタ引数とかで何を指定する必要があるのかとかが分からなさ過ぎた。 最低限動かすのに必要になった以下の Bean 達について、それぞれの役割についていろい…

ドメインオブジェクトセキュリティの勉強再開

ObjectIdentityImpl oi = new ObjectIdentityImpl(Foo.class, 44L); MutableAcl acl = this.aclService.createAcl(oi); とか ObjectIdentityImpl oi = new ObjectIdentityImpl(Foo.class, 44L); MutableAcl acl = this.aclService.createAcl(oi); System.out…

2.3. Domain Classes

Spring Security ACL Plugin - Reference Documentation The plugin uses domain classes to manage database state. プラグインはドメインクラスをデータベースの状態を管理するために使用します。 Ordinarily the database structure isn’t all that impor…

2.1. Securing Service Methods

Spring Security ACL Plugin - Reference Documentation There are two primary use cases for ACL security: determining whether a user is allowed to perform an action on an instance before the action is invoked, and restricting access to single…

1. Introduction to the Spring Security ACL Plugin

Spring Security ACL Plugin - Reference Documentation 1. Introduction to the Spring Security ACL Plugin The ACL plugin adds Domain Object Security support to a Grails application that uses Spring Security. ACL プラグインは、 Spring Security…

ACL 勉強中苦戦中

たぶんドメインオブジェクト(特定のデータ)単位でアクセス制御をできるようにするための仕組みなんだけど、リファレンスに載ってるサンプルの情報が不足しすぎてて苦戦中。 なんとか必要そうな Bean を定義したが、トランザクション管理が必要と言われたと…

CORS を勉強した

Spring Security の CORS についていろいろ動作確認した。 わりとすっきりしてて分かりやすい印象。 設定書くだけで preflight request とか勝手にやってくれるのは便利でいいなぁって思った。

CSRF のトークンを Cookie にした場合の secure 属性の指定

よく考えたら記事に書いてなかったなぁと仕事中に思い出したので調べた。 <csrf> タグの属性とかで指定できるのかなぁと思ったら、 IntelliJ の補完で属性が3つしか表示されない。 しかたないので実装(CookieCsrfTokenRepository)を見に行ったら、↓のようになっ</csrf>…

19. CORS

Spring Framework provides first class support for CORS. Spring Framework は CORS をサポートするクラスを提供します。 CORS must be processed before Spring Security because the pre-flight request will not contain any cookies (i.e. the JSESSIO…

Remember-Me のログイン時のパラメータの謎について追う

Remember-Me 認証でログインするときに、フォームには <input type="checkbox" name="remember-me" /> を追加しておけばいい。 けど、 value 属性を省略した場合って、なんの値が渡っているのだろう? 実際に動かしたら、 on という値が渡っていた。 <input type="checkbox"> - HTML | MDN value (略)省略された場合は、要素の …

Run-As についていろいろ試した

Run-As について Hello World から気になる点までを一通り調べた。 ただ、結局 RunAsImplAuthenticationProvider の価値については分からなかった。 そもそも、この機能を使う機会はあるのかもあやしいが。

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. Abstract…

HttpFirewall について勉強

HttpServletRequest や HttpServletResponse をラップして、危険な操作を未然に防ぐ機能。 結構いろんなことやってるのかなぁとか思ってたけど、意外とやってることは少なくて、書くこともあまりなかった。

Formログインに関する微調整とかを調査中

ログインURL の変更とか、そういうのをこまごま検証中。 assertjGen にバグ報告があったりとか、 JDT2017 の登録とか、ぴあの情報流出問題の確認とか、明日の関Java の準備とか色々別作業で手を取られたのであまり進んでない。

同時セッション制御についていろいろ試した

<concurrency-control> の error-if-maximum-exceeded を true にした場合で、 Remember-Me を組み合わせた場合にうまくエラー制御ができない問題を色々試した。 結局、回避方法は分からなかった。 実装見る限り、回避は無理っぽい気がするが、、、</concurrency-control>

6.3.3 Session Management

Detecting Timeouts You can configure Spring Security to detect the submission of an invalid session ID and redirect the user to an appropriate URL. あなたは、無効なセッションIDが渡されたことを検出し、適切な URL にリダイレクトするために Spr…

SessionManagementFilter の価値がようやくわかった気がする

Session Management について勉強開始。 翻訳は以前していた。 SessionManagementFilter セッション管理するフィルター。 SecurityContextRepository に SecurityContext が無かったら何もしない あったら Authentication を取り出す Authenticaiton が匿名…

HPKP について調べてたけどあきらめた

HPKP (HTTP Public Key Pinning) について調べてたが、あきらめた。 pin の設定がよくわからんし、上手くブロックされたところを調べるための環境を用意するのが面倒そう。 それに 自堕落な技術者の日記 : HPKP(HTTP Public Key Pinning)公開鍵ピニングにつ…

X-XSS-Protection を試した

<%@page contentType="text/html" pageEncoding="UTF-8"%> <html> <head> <meta charset="utf-8" /> <title>Reflected XSS</title> </head> <body> <h1>Reflected XSS</h1> ${param["q"]} </body> </html> こんな感じの JSP を作って、 “?q=alert("Hey”);“ みたいなクエリパラメータを乗せたリクエストを送る。 X-XSS-Protection ヘッダーが設定され…

Strict-Transport-Security を試した

HTTP Strict-Transport-Security の動作について実際に動かして試した。 HTTPS 通信の検証については、 Payara (GlassFish) を使っていればデフォルトで 8181 ポートにアクセスすれば HTTPS で通信できるので、それを利用(証明書の作成とかインポートとか面…

X-Frame-Options の変更を試した

デフォルトだとレスポンスヘッダーに Cache-Control: no-cache, no-store, max-age=0, must-revalidate Pragma: no-cache Expires: 0 X-Content-Type-Options: nosniff X-Frame-Options: DENY X-XSS-Protection: 1; mode=block がついていることを確認。 こ…

20.2.3 DelegatingRequestMatcherHeaderWriter

20.2.3 DelegatingRequestMatcherHeaderWriter At times you may want to only write a header for certain requests. ときどき、あなたは一定のリクエストでだけヘッダーを書きたいと思うことでしょう。 For example, perhaps you want to only protect you…

20.2.2 Headers Writer

20.2.2 Headers Writer When the namespace or Java configuration does not support the headers you want, you can create a custom HeadersWriter instance or even provide a custom implementation of the HeadersWriter. namespace か Java Configurat…

20.2 Custom Headers, 20.2.1 Static Headers

20.2 Custom Headers Spring Security has mechanisms to make it convenient to add the more common security headers to your application. Spring Security はより共通のセキュリティヘッダーをアプリケーションに追加することを便利にするメカニズムを…

20.1.8 Referrer Policy

20.1.8 Referrer Policy Referrer Policy is a mechanism that web applications can leverage to manage the referrer field, which contains the last page the user was on. Referer ポリシーは Web アプリケーションがユーザーが最後にアクセスしていた…

20.1.7 Content Security Policy (CSP)

20.1.7 Content Security Policy (CSP) Content Security Policy (CSP) is a mechanism that web applications can leverage to mitigate content injection vulnerabilities, such as cross-site scripting (XSS). Content Security Policy は、 Web アプリ…

20.1.6 X-XSS-Protection

正しさの保証なんてものは(ry 20.1.6 X-XSS-Protection Some browsers have built in support for filtering out reflected XSS attacks. いくつかのブラウザは Refrected XSS 攻撃を回避する組み込みのサポートを持っています。 ※Referected XSS 攻撃 反…