Конфигурация Spring Security:
Код: Выделить всё
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
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;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import shoppinglist.service.configurations.security.oauth2userService.CustomOAuth2UserService;
import shoppinglist.service.configurations.security.oauth2userService.CustomOidcUserService;
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled=true)
@EnableWebSecurity
@RequiredArgsConstructor
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private final CustomOidcUserService customOidcUserService;
@Autowired
private final CustomOAuth2UserService customOAuth2UserService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable()
.cors().disable()
.authorizeRequests()
.antMatchers("/**").permitAll()
.and()
.oauth2Login()
.userInfoEndpoint().oidcUserService(customOidcUserService).userService(customOAuth2UserService)
.and().defaultSuccessUrl("/", true)
.and()
)
.logout(l -> l
.logoutSuccessUrl("/").permitAll()
);
}
}
Он отлично работает в браузере, но я не могу найти способ сделать это с помощью flutter.
Самое большее, что мне удалось сделать, это использовать библиотека под названием "flutter_web_auth":
Код: Выделить всё
Future oauth2(String provider) async {
final String url = "http://10.0.2.2.nip.io:8080/oauth2/authorization/google";
final String result = await FlutterWebAuth.authenticate(
url: url, callbackUrlScheme: '10.0.2.2.nip:8080');
}
CallbackUrlScheme также находится в AndroidManifest.xml.
Код: Выделить всё
Я был бы очень признателен за вашу помощь, и если у вас есть другие предложения, кроме flutter_web_auth, дайте мне знать.
И как мне тогда сохранить JSESSIONID?
Подробнее здесь: https://stackoverflow.com/questions/707 ... ot-backend