Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
正井
Uploaded by
正和 井岡
PPTX, PDF
2,114 views
Spring Security 4.1 の新機能
日本Springユーザ会SpringOne Platform 2016報告会で、Spring Security 4.1の新機能の紹介
Technology
◦
Read more
3
Save
Share
Embed
Embed presentation
Download
Downloaded 19 times
1
/ 14
2
/ 14
3
/ 14
4
/ 14
5
/ 14
6
/ 14
7
/ 14
8
/ 14
9
/ 14
10
/ 14
11
/ 14
12
/ 14
13
/ 14
14
/ 14
More Related Content
PDF
Spring Framework ふりかえりと4.3新機能
by
kimulla
PDF
Spring Security 5.0 解剖速報
by
Takuya Iwatsuka
PDF
どこよりも早い Spring Boot 1.2 解説 #渋谷Java
by
Toshiaki Maki
PPTX
SPAセキュリティ入門~PHP Conference Japan 2021
by
Hiroshi Tokumaru
PDF
Spring integration概要
by
kuroiwa
PPTX
Spring Integration 超入門
by
Yasutaka Sugamura
PDF
Spring I/O 2016 報告 Test / Cloud / Other Popular Sessions
by
Takuya Iwatsuka
PDF
Spring bootでweb 基本編
by
なべ
Spring Framework ふりかえりと4.3新機能
by
kimulla
Spring Security 5.0 解剖速報
by
Takuya Iwatsuka
どこよりも早い Spring Boot 1.2 解説 #渋谷Java
by
Toshiaki Maki
SPAセキュリティ入門~PHP Conference Japan 2021
by
Hiroshi Tokumaru
Spring integration概要
by
kuroiwa
Spring Integration 超入門
by
Yasutaka Sugamura
Spring I/O 2016 報告 Test / Cloud / Other Popular Sessions
by
Takuya Iwatsuka
Spring bootでweb 基本編
by
なべ
What's hot
PDF
SpringOne 2GX 2014 参加報告 & Spring 4.1について #jsug
by
Toshiaki Maki
PDF
Yahoo! JAPANのコンテンツプラットフォームを支えるSpring Cloud Streamによるマイクロサービスアーキテクチャ #jsug #sf_52
by
Yahoo!デベロッパーネットワーク
PDF
Vue入門
by
Takeo Noda
PDF
Spring bootでweb セキュリティ(ログイン認証)編
by
なべ
PDF
Spring Bootで変わる Javaアプリ開発! #jsug
by
Toshiaki Maki
PDF
Spring Fest 2018 Spring Bootで作るRESTful Web Service
by
WataruOhno
PPTX
未来のwebに欠かせないREST APIをApache Solr + Drupal8で実装しよう@PHPカンファレンス2016 東京
by
Masayuki Abe
PPTX
Spring data-rest-and-spring-cloud-contract
by
Takeshi Ogawa
PDF
イエラエセキュリティMeet up 20210820
by
GMOサイバーセキュリティ byイエラエ株式会社
PDF
Laravelの認証について
by
Takeo Noda
PDF
Spring I/O 2017 報告 ThymeleafのWebFlux対応
by
Takuya Iwatsuka
PDF
WildFly Swarm - Rightsize Your Java EE Apps
by
Yoshimasa Tanabe
PDF
Spring AMQP × RabbitMQ
by
Keisuke Nishitani
PPTX
はじめてのSpring Boot
by
なべ
PPTX
ウェブ・セキュリティ基礎試験(徳丸基礎試験)の模擬試験問題
by
Hiroshi Tokumaru
PDF
Jsug 20160422 slides
by
Yuichi Hasegawa
PPTX
[JavaDo] JAX-RS ハンズオン 第2部
by
haruki ueno
PPTX
今からでも間に合う!インフラ自動化超入門 @渋谷
by
Daigou Harada
PPTX
Excel on OneDrive is not a file
by
Takao Tetsuro
PDF
Go conference 2015_winter
by
matsuo kenji
SpringOne 2GX 2014 参加報告 & Spring 4.1について #jsug
by
Toshiaki Maki
Yahoo! JAPANのコンテンツプラットフォームを支えるSpring Cloud Streamによるマイクロサービスアーキテクチャ #jsug #sf_52
by
Yahoo!デベロッパーネットワーク
Vue入門
by
Takeo Noda
Spring bootでweb セキュリティ(ログイン認証)編
by
なべ
Spring Bootで変わる Javaアプリ開発! #jsug
by
Toshiaki Maki
Spring Fest 2018 Spring Bootで作るRESTful Web Service
by
WataruOhno
未来のwebに欠かせないREST APIをApache Solr + Drupal8で実装しよう@PHPカンファレンス2016 東京
by
Masayuki Abe
Spring data-rest-and-spring-cloud-contract
by
Takeshi Ogawa
イエラエセキュリティMeet up 20210820
by
GMOサイバーセキュリティ byイエラエ株式会社
Laravelの認証について
by
Takeo Noda
Spring I/O 2017 報告 ThymeleafのWebFlux対応
by
Takuya Iwatsuka
WildFly Swarm - Rightsize Your Java EE Apps
by
Yoshimasa Tanabe
Spring AMQP × RabbitMQ
by
Keisuke Nishitani
はじめてのSpring Boot
by
なべ
ウェブ・セキュリティ基礎試験(徳丸基礎試験)の模擬試験問題
by
Hiroshi Tokumaru
Jsug 20160422 slides
by
Yuichi Hasegawa
[JavaDo] JAX-RS ハンズオン 第2部
by
haruki ueno
今からでも間に合う!インフラ自動化超入門 @渋谷
by
Daigou Harada
Excel on OneDrive is not a file
by
Takao Tetsuro
Go conference 2015_winter
by
matsuo kenji
Similar to Spring Security 4.1 の新機能
PDF
OAuth2.0によるWeb APIの保護
by
Naohiro Fujie
PPTX
Spring Fest 2017 「エンタープライズで利用するSpring Boot」#jsug #sf_h1
by
Takeshi Hirosue
PDF
Use JWT access-token on Grails REST API
by
Uehara Junji
PDF
Spring fest2020 spring-security
by
土岐 孝平
PDF
Microservices /w Spring Security OAuth
by
Makoto Kakuta
PPTX
Webアプリ開発実践tips共有会
by
tomo730
PDF
OAuth 2.0 MAC Authentication
by
Ryo Ito
OAuth2.0によるWeb APIの保護
by
Naohiro Fujie
Spring Fest 2017 「エンタープライズで利用するSpring Boot」#jsug #sf_h1
by
Takeshi Hirosue
Use JWT access-token on Grails REST API
by
Uehara Junji
Spring fest2020 spring-security
by
土岐 孝平
Microservices /w Spring Security OAuth
by
Makoto Kakuta
Webアプリ開発実践tips共有会
by
tomo730
OAuth 2.0 MAC Authentication
by
Ryo Ito
Recently uploaded
PDF
第21回 Gen AI 勉強会「NotebookLMで60ページ超の スライドを作成してみた」
by
嶋 是一 (Yoshikazu SHIMA)
PDF
20260119_VIoTLT_vol22_kitazaki_v1___.pdf
by
Ayachika Kitazaki
PDF
Starlink Direct-to-Cell (D2C) 技術の概要と将来の展望
by
CRI Japan, Inc.
PDF
ST2024_PM1_2_Case_study_of_local_newspaper_company.pdf
by
akipii ogaoga
PDF
Team Topology Adaptive Organizational Design for Rapid Delivery of Valuable S...
by
akipii ogaoga
PDF
100年後の知財業界-生成AIスライドアドリブプレゼン イーパテントYouTube配信
by
e-Patent Co., Ltd.
PDF
アジャイル導入が止まる3つの壁 ─ 文化・他部門・組織プロセスをどう乗り越えるか
by
Graat(グラーツ)
PDF
FY2025 IT Strategist Afternoon I Question-1 Balanced Scorecard
by
akipii ogaoga
PDF
Reiwa 7 IT Strategist Afternoon I Question-1 3C Analysis
by
akipii ogaoga
PDF
Reiwa 7 IT Strategist Afternoon I Question-1 Ansoff's Growth Vector
by
akipii ogaoga
第21回 Gen AI 勉強会「NotebookLMで60ページ超の スライドを作成してみた」
by
嶋 是一 (Yoshikazu SHIMA)
20260119_VIoTLT_vol22_kitazaki_v1___.pdf
by
Ayachika Kitazaki
Starlink Direct-to-Cell (D2C) 技術の概要と将来の展望
by
CRI Japan, Inc.
ST2024_PM1_2_Case_study_of_local_newspaper_company.pdf
by
akipii ogaoga
Team Topology Adaptive Organizational Design for Rapid Delivery of Valuable S...
by
akipii ogaoga
100年後の知財業界-生成AIスライドアドリブプレゼン イーパテントYouTube配信
by
e-Patent Co., Ltd.
アジャイル導入が止まる3つの壁 ─ 文化・他部門・組織プロセスをどう乗り越えるか
by
Graat(グラーツ)
FY2025 IT Strategist Afternoon I Question-1 Balanced Scorecard
by
akipii ogaoga
Reiwa 7 IT Strategist Afternoon I Question-1 3C Analysis
by
akipii ogaoga
Reiwa 7 IT Strategist Afternoon I Question-1 Ansoff's Growth Vector
by
akipii ogaoga
Spring Security 4.1 の新機能
1.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. Spring Security 4.1 の新機能 2016/09/03 新日鉄住金ソリューションズ株式会社 井岡 正和 日本Springユーザ会 SpringOne Platform 2016 報告会
2.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. 自己紹介 井岡 正和 (いおか まさかず) Spring ベースの社内標準FW開発・保守担当 SpringOne の参加は3回目 プライベートでは、iOS・Android のアプリを開発 http://www.slideshare.net/KoUmetani/spring2015-56309694 去年もSpring Security 関連について 紹介させていただきました。 2
3.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. 今日紹介する内容 Spring Security 4.1 の新機能について CookieCsrfTokenRepository Content Security Policy @AuthenticationPrincipal Path Variables in Web Security Expressions Referring to Beans in Web Security Expressions MvcRequestMatcher 3 参考セッション: To Spring Security 4.1 and Beyond セッションで使用されたコード: https://github.com/rwinch/spring-security-4.1-and-beyond
4.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. (おさらい) Spring Security の基本的な使い方 @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { // @formatter:off @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .anyRequest().authenticated() .and() .httpBasic(); } // @formatter:on WebSecurityConfigurerAdapter を継承 @EnableWebSecurity を追加 configure をオーバーライド リソースへのアクセス許可 Basic認証を有効 その他のアクセスに認証 自分で指定したインデントがIDEのフォーマッタで崩れてしまうが、 「// @formatter:off」と「// @formatter:on」で囲うことで、 その中のコードはフォーマッターがかからなくなる。 4
5.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. Spring Security 4.1 の 新機能について 5
6.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. CookieCsrfTokenRepository 6 CSRF トークンを Cookie に格納できるようになった デフォルトでは「XSRF-TOKEN」に格納される AngularJS では、Cookie に XSRF-TOKEN があると、 自動的に X-XSRF-TOKEN ヘッダを付けてくれるらしい @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .anyRequest().authenticated() .and() .httpBasic() .and() .csrf() .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); } CSRF の CsrfTokenRepository に、 CookieCsrfTokenRepository を指定 JavaScript 等から読み込む場合は、 withHttpOnlyFalse() によって CsrfTokenRepository を取得する。
7.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. Content Security Policy 7 Content Security Policy の設定ができるようになった XSS やデータインジェクション等の攻撃を対策できる @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .anyRequest().authenticated() .and() .httpBasic() .and() .headers() .contentSecurityPolicy("default-src 'self' " + "https://ajax.googleapis.com; " + "style-src 'self' 'unsafe-inline'"); } ヘッダに Content Security Policy を設定 contentSecurityPolicy() の後ろに「.reportOnly()」 を追加すると、ポリシー違反の通知のみになる。 ここでの設定では、 自身のドメインと「https://ajax.googleapis.com」を許可 スタイルについては自身のドメインとインラインの<style>要素のみ許可
8.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. @AuthenticationPrincipal (1/2) 8 認証ユーザを Controller の引数で取得できるようになった @RestController public class SecurityController { @RequestMapping(value = "/principal") public ResponseEntity<User> currentPrincipal(@AuthenticationPrincipal User user) { return new ResponseEntity<User>(user, HttpStatus.OK); } これだけ! 以前は、下記のようにして取得していた @RequestMapping(value = "/principal") public ResponseEntity<User> currentPrincipal() { User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); @RequestMapping(value = "/principal") public ResponseEntity<User> currentPrincipal(Authentication authentication) { User user = (User) authentication.getPrincipal(); 大変!
9.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. @AuthenticationPrincipal (2/2) 9 ただし、@AuthenticationPrincipal は直接使用せず、 @CurrentUser のように意味が伝わるアノテーションを 作成して使用したほうが保守性が上がる @RestController public class SecurityController { @RequestMapping(value = "/principal") public ResponseEntity<User> currentPrincipal(@CurrentUser User user) { return new ResponseEntity<User>(user, HttpStatus.OK); } @Target(ElementType.PARAMETER) @Retention(RetentionPolicy.RUNTIME) @Documented @AuthenticationPrincipal public @interface CurrentUser { }
10.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. Path Variables in Web Security Expressions 10 Web Security Expressions で Path Variable を 使用できるようになった @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .antMatchers("/users/{userId}").access("#userId == principal.id.toString()") .anyRequest().authenticated() .and() .httpBasic(); } @RequestMapping と同じで 中括弧で変数を指定 「#変数名」で使用できる
11.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. Referring to Beans in Web Security Expressions 11 Web Security Expressions で Bean を 使用できるようになった @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .antMatchers("/users/{userId}").access("@authz.check(#userId,principal)") .anyRequest().authenticated() .and() .httpBasic(); } 「@Bean名」で使用できる @Component public class Authz { public boolean check(Long userId, User user) { return userId.equals(user.getId()); } } 「authz」というBean名で登録される @PreAuthorize や@PostAuthorize 等でも Bean を使用できる
12.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. MvcRequestMatcher 12 「/admin」のアクセス制限をした場合に、 「/admin/」からもアクセス制限できるようになった @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .mvcMatchers("/admin").denyAll() .anyRequest().authenticated() .and() .httpBasic(); } antMatchers ではなく、 mvcMatchers を使用する @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/", "/assets/**", "/webjars/**").permitAll() .antMatchers("/admin").denyAll() .anyRequest().authenticated() .and() .httpBasic(); } 下記のように antMatchers("/admin").denyAll() とした場合は、 「/admin/」でアクセスできる
13.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. おわりに 13 とても簡単にセキュリティ設定ができるので、 強固なアプリケーションを作ってください! 他にもいろいろな機能が 4.1 で追加されています http://docs.spring.io/spring- security/site/docs/current/reference/htmlsingle/#new
14.
Copyright ©2016 NS
Solutions Corporation. All Rights Reserved. 14 NS Solutions、NS(ロゴ)、NSSOLは、新日鉄住金ソリューションズ株式会社の登録商標です。 Javaは、米国ORACLE Corp.の登録商標です。 その他本文記載の会社名及び製品名は、それぞれ各社の商標又は登録商標です。
Download