برنامه نویسی

احراز هویت یک برنامه Spring Boot با Active Directory

Summarize this content to 400 words in Persian Lang
احراز هویت با Active Directory در یک برنامه Spring Boot ساده است و به حداقل تنظیمات نیاز دارد. برای آزمایش اتصال یا بسته های پیچیده اضافی، نیازی به نصب سرور تعبیه شده ندارید. در واقع، این فرآیند تنها با چند وابستگی و یک پیکربندی ساده ساده شده است.

وابستگی ها

ابتدا اطمینان حاصل کنید که وابستگی های لازم را در خود دارید pom.xml یا build.gradle:

org.springframework.security
spring-security-ldap

org.springframework.boot
spring-boot-starter-data-ldap

وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

پیکربندی

بعد، Spring Security خود را در a پیکربندی کنید WebSecurityConfig کلاس:

@EnableWebSecurity
public class WebSecurityConfig{

@Bean
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
.authorizeHttpRequests((authorize) -> authorize.anyRequest().fullyAuthenticated())
.formLogin(Customizer.withDefaults());

return http.build();

@Bean
public ActiveDirectoryLdapAuthenticationProvider authenticationProvider() {
return new ActiveDirectoryLdapAuthenticationProvider(“domain.com”, “ldap://ip-addr”);
}
}

وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

و بس، ایمن شدن مبارک 😎 !!

احراز هویت با Active Directory در یک برنامه Spring Boot ساده است و به حداقل تنظیمات نیاز دارد. برای آزمایش اتصال یا بسته های پیچیده اضافی، نیازی به نصب سرور تعبیه شده ندارید. در واقع، این فرآیند تنها با چند وابستگی و یک پیکربندی ساده ساده شده است.

وابستگی ها

ابتدا اطمینان حاصل کنید که وابستگی های لازم را در خود دارید pom.xml یا build.gradle:


    org.springframework.security
    spring-security-ldap


    org.springframework.boot
    spring-boot-starter-data-ldap

وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

پیکربندی

بعد، Spring Security خود را در a پیکربندی کنید WebSecurityConfig کلاس:

@EnableWebSecurity
public class WebSecurityConfig{

    @Bean
    SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authorize) -> authorize.anyRequest().fullyAuthenticated())
            .formLogin(Customizer.withDefaults());

        return http.build();

    @Bean
    public ActiveDirectoryLdapAuthenticationProvider authenticationProvider() {
        return new ActiveDirectoryLdapAuthenticationProvider("domain.com", "ldap://ip-addr");
    }
}

وارد حالت تمام صفحه شوید

از حالت تمام صفحه خارج شوید

و بس، ایمن شدن مبارک 😎 !!

نوشته های مشابه

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *

دکمه بازگشت به بالا