2

API の開発に spring-data-rest を使用していますが、Spring セキュリティを使用してリクエストを認証する必要があります。認証の詳細を渡すと、API + 秘密鍵を生成してクライアント側に保存し、そのサブジェクトからの以降のすべての要求と共に送信する必要があります。そして、すべてのリクエストでそれを確認する必要があり、ログアウトした場合は、再度ログインするときにキーを再生成する必要があります。このようにセキュリティを実装しましたが、

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
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;

@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter{


    @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception{
        auth.inMemoryAuthentication()
            .withUser("test").password("test").roles("test");
    }

    @Override protected void configure(HttpSecurity http) throws Exception{
        http.authorizeRequests()
            .antMatchers("/**").hasRole("test")
            .anyRequest().anonymous()
            .and()
            .httpBasic()
            .and()
            .csrf()
            .disable();
    }

}

Java構成を介してフィルターを登録しました。

そして、探しているのとまったく同じこのチュートリアルを見ました。バネが苦手なので、ちゃんと動いているか知りたいです。

私のサイトでは Facebook ログインを実装し、登録は不要です。誰もが Facebook でログインして、サイトまたは私のアプリにアクセスします。だから私もパスワードを持っていません。これを達成するためにどのように進歩できるか、適切な方法で私を導いてください。前もって感謝します。

4

0 に答える 0