Я перешел на самую базовую конфигурацию SAML, и она не работает! См. ниже. Его расположение находится в каталоге ресурсов. Также там находятся учетные данные и файл okta.
Код: Выделить всё
server:
port: 8080
logging:
level:
root: INFO
org.springframework.web: DEBUG
org.springframework.security: DEBUG
org.springframework.security.saml: TRACE
org.opensaml.xmlsec: DEBUG
pattern:
console: "%d{HH:mm:ss.SSS} %-5level - %msg%n"
spring:
security:
saml2:
relyingparty:
registration:
appname:
signing:
credentials:
- private-key-location: "classpath:credentials/private.key"
certificate-location: "classpath:credentials/certificate.crt"
decryption:
credentials:
- private-key-location: "classpath:credentials/private.key"
certificate-location: "classpath:credentials/certificate.crt"
assertingparty:
metadata-uri: "https://integrator-NNNN.okta.com/"
20:29:21.486 ПРЕДУПРЕЖДЕНИЕ — исключение, возникшее во время инициализации контекста — отмена попытки обновления: org.springframework.beans.factory.BeanCreationException: ошибка создания bean-компонента с именем «filterChain», определенный в ресурсе пути к классу [org/mudra/demosaml/BootSecurityConfig.class]: не удалось создать экземпляр [org.springframework.security.web.SecurityFilterChain]: фабричный метод «filterChain» выдал исключение с сообщением: relingingPartyRegistrationRepository не может быть нулевым
Мой класс конфигурации так же прост, как
Код: Выделить всё
@Configuration
public class BootSecurityCon fig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests(authorize ->
authorize.anyRequest().authenticated())
.saml2Login(withDefaults());
return http.build();
}
}
Код: Выделить всё
@Bean
public RelyingPartyRegistrationRepository relyingPartyRegistrations() throws Exception {
ClassPathResource keyResource
= new ClassPathResource("credentials/private.key");
ClassPathResource crtResource
= new ClassPathResource("credentials/certificate.crt");
// Load your private key and certificate
RSAPrivateKey key = (RSAPrivateKey) KeySupport.decodePrivateKey(
keyResource.getInputStream(), null);
Collection certs = X509Support.decodeCertificates(
crtResource.getInputStream());
// Create the credential specifically for decryption
Saml2X509Credential decryption = Saml2X509Credential.decryption(
key, certs.iterator().next());
Saml2X509Credential signing = Saml2X509Credential.signing(
key, certs.iterator().next());
RelyingPartyRegistration registration = RelyingPartyRegistrations
.fromMetadataLocation("https://integrator-NNN.okta.com/")
.registrationId("appname")
.decryptionX509Credentials(c -> c.add(decryption) .signingX509Credentials(c -> c.add(signing))
.build();
return new InMemoryRelyingPartyRegistrationRepository(registration);
}
Код: Выделить всё
org.springframework.boot
spring-boot-starter-security
org.springframework.boot
spring-boot-starter-webmvc
org.springframework.security
spring-security-saml2-service-provider
У кого-нибудь есть какие-нибудь мысли?
Подробнее здесь: https://stackoverflow.com/questions/798 ... -yaml-file
Мобильная версия