Spring Cloud 云身份識別代理(IAP)身份驗證

2024-01-11 16:17 更新

Cloud Identity-Aware Proxy(IAP)為部署到Google Cloud的應(yīng)用程序提供了安全層。

IAP入門人員使用Spring Security OAuth 2.0資源服務(wù)器功能從注入代理的x-goog-iap-jwt-assertion HTTP標(biāo)頭中自動提取用戶身份。

以下聲明將自動驗證:

  • 發(fā)行時間
  • 到期時間
  • 發(fā)行人
  • 聽眾

當(dāng)應(yīng)用程序在App Engine Standard或App Engine Flexible上運行時,將自動配置受眾群體("aud")驗證。對于其他運行時環(huán)境,必須通過spring.cloud.gcp.security.iap.audience屬性提供自定義受眾。 自定義屬性(如果已指定)將覆蓋自動的App Engine受眾群體檢測。

Compute Engine或Kubernetes Engine沒有自動的受眾字符串配置。要在GCE / GKE上使用IAP啟動器, 在“驗證JWT有效負(fù)載”指南中按照說明查找受眾字符串,并在spring.cloud.gcp.security.iap.audience屬性中進(jìn)行指定。 否則,應(yīng)用程序?qū)o法以No qualifying bean of type 'org.springframework.cloud.gcp.security.iap.AudienceProvider' available消息啟動。

如果創(chuàng)建自定義WebSecurityConfigurerAdapter ,請通過向HttpSecurity對象 添加.oauth2ResourceServer().jwt()配置來提取用戶身份。如果沒有自定義項,WebSecurityConfigurerAdapter則無需執(zhí)行任何操作,因為Spring Boot將默認(rèn)添加此自定義項。

起始Maven坐標(biāo),使用Spring Cloud GCP BOM

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gcp-starter-security-iap</artifactId>
</dependency>

入門級Gradle坐標(biāo):

dependencies {
    compile group: 'org.springframework.cloud', name: 'spring-cloud-gcp-starter-security-iap'
}
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號