私は春のセキュリティなしで春の雲の設定サーバーを実行すると、サービスは問題なく設定を取得しますが、私は春のセキュリティをアクティブにしたときには、設定ファイルを取得しません。401 HTTPエラーを投げているようです。同じ問題で認証のパスワード@ URLの道:私は、ユーザー名とパスワードが正しいことをチェックして、私はまた、ユーザーを試してみました。
私は、URLにアクセスするとhttp://localhost:8888/service/default
、ブラウザで直接コンフィグが表示されているユーザー名とパスワードを入力します。
すべてのヘルプは、私のクラウドconfigまたは私のセキュリティの設定に問題がある場合、私はわからない、理解されるであろう。
春のブートバージョン:「2.2.4.RELEASE」
春・クラウド・コンフィグ・サーバのバージョン:「2.2.1.RELEASE」
ビルドシステム:Gradleの
Javaの8
私は春の初期化子を経由して新しい設定サーバーと新しいクライアントを作成したように、この設定は常に失敗し、私は私が持っていた既存のサービスに追加しようと、それはうまくいきませんでしたhttps://start.spring.io/以下の設定とし、まだ動作しません。
セキュリティがアクティブなときにログインします。
2020-02-19 14:29:16.553 INFO 14996 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-19 14:29:16.577 DEBUG 14996 --- [ main] o.s.web.client.RestTemplate : HTTP GET http://localhost:8888/service/default
2020-02-19 14:29:16.634 DEBUG 14996 --- [ main] o.s.web.client.RestTemplate : Accept=[application/json, application/*+json]
2020-02-19 14:29:16.647 DEBUG 14996 --- [ main] o.s.web.client.RestTemplate : Response 401 UNAUTHORIZED
2020-02-19 14:29:16.652 WARN 14996 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 401 : [{"timestamp":"2020-02-19T12:29:16.642+0000","status":401,"error":"Unauthorized","message":"Unauthorized","path":"/service/default"}]
セキュリティが無効になっているログイン時に/全て許可
2020-02-19 12:43:13.756 INFO 4972 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-19 12:43:17.563 INFO 4972 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=service, profiles=[default], label=null, version=fb9ccb6e46098bfe425130d6447a0797206e5c2f, state=null
サーバーapplication.yml configファイル
URIが隠されているgithubのを、民間のレポへの接続は問題ではありません。
server:
port: 8888
spring:
application:
name: config-server
security:
user:
name: 'root'
password: '1234'
cloud:
config:
server:
git:
uri: <github-uri>
ignore-local-ssh-settings: false
strict-host-key-checking: false
private-key: 'classpath:resources/id_rsa'
サービスapplication.ymlファイル
spring:
application:
name: service
cloud:
config:
uri: http://localhost:8888
username: 'root'
password: '1234'
fail-fast: true
Webセキュリティは非常に基本的なものですが、以下のセキュリティ設定です。
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
// Secure the endpoints with HTTP Basic authentication
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").fullyAuthenticated();
http.httpBasic().and().exceptionHandling();
}
}
あなたは使用する必要がありますbootstrap.yaml
(ないapplication.yaml
クライアントアプリケーションのために)。
それはあなたのクライアントは、ユーザー名とパスワードを持っていないデフォルトの設定を、使用しているという理由だけで、セキュリティなしで動作します。あなたは、セキュリティを有効にすると、デフォルトのユーザー名とパスワードが空であるため、それは401を返します。