EurekaオープンHTTP Baic認証
2606 ワード
1つ エウレカ Server
1 設定ファイル
appication.yml
1 appication.yml
1 Eurekaを起動します Server
1 入力http://localhost:8761/eureka/apps
2 次のページをイジェクトして、ユーザー名とパスワードを入力します.
3 ポップアップの結果は以下の通りです
1 設定ファイル
appication.yml
spring:
profiles:
active: security
appication-security.ymlserver:
port: 8761
spring:
security:
basic:
enabled: true
user:
name: admin
password: Xk38CNHigBP5jK75
eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
server:
waitTimeInMsWhenSyncEmpty: 0
enableSelfPreservation: false
2 csrfプロファイルpackage cn.springcloud.book.config;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
* Created by caibosi on 2018-06-25.
*/
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http.csrf().disable();
}
}
二番目 エウレカ Cient1 appication.yml
spring:
profiles:
active: security
2 appication-security.ymlserver:
port: 8081
spring:
application:
name: client1
eureka:
client:
security:
basic:
user: admin
password: Xk38CNHigBP5jK75
serviceUrl:
defaultZone: http://${eureka.client.security.basic.user}:${eureka.client.security.basic.password}@localhost:8761/eureka/
三番目 起動1 Eurekaを起動します Server
mvn spring-boot:run -Dspring.profiles.active=security
2 Eurekaを起動します Cientmvn spring-boot:run -Dspring.profiles.active=security
四番目 テスト1 入力http://localhost:8761/eureka/apps
2 次のページをイジェクトして、ユーザー名とパスワードを入力します.
3 ポップアップの結果は以下の通りです