@Override public Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentication principal, ServerWebExchange exchange) { Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty"); Assert.notNull(exchange, "exchange cannot be null"); return exchange.getSession() .doOnSuccess(session -> { Map<String, OAuth2AuthorizedClient> authorizedClients = getAuthorizedClients(session); authorizedClients.remove(clientRegistrationId); if (authorizedClients.isEmpty()) { session.getAttributes().remove(this.sessionAttributeName); } else { session.getAttributes().put(this.sessionAttributeName, authorizedClients); } }) .then(Mono.empty()); }
@Override public Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal, ServerWebExchange exchange) { Assert.notNull(authorizedClient, "authorizedClient cannot be null"); Assert.notNull(exchange, "exchange cannot be null"); return exchange.getSession() .doOnSuccess(session -> { Map<String, OAuth2AuthorizedClient> authorizedClients = getAuthorizedClients(session); authorizedClients.put(authorizedClient.getClientRegistration().getRegistrationId(), authorizedClient); session.getAttributes().put(this.sessionAttributeName, authorizedClients); }) .then(Mono.empty()); }
@Override public Mono<Void> removeAuthorizedClient(String clientRegistrationId, Authentication principal, ServerWebExchange exchange) { Assert.hasText(clientRegistrationId, "clientRegistrationId cannot be empty"); Assert.notNull(exchange, "exchange cannot be null"); return exchange.getSession() .doOnSuccess(session -> { Map<String, OAuth2AuthorizedClient> authorizedClients = getAuthorizedClients(session); authorizedClients.remove(clientRegistrationId); if (authorizedClients.isEmpty()) { session.getAttributes().remove(this.sessionAttributeName); } else { session.getAttributes().put(this.sessionAttributeName, authorizedClients); } }) .then(Mono.empty()); }
@Override public Mono<Void> saveAuthorizedClient(OAuth2AuthorizedClient authorizedClient, Authentication principal, ServerWebExchange exchange) { Assert.notNull(authorizedClient, "authorizedClient cannot be null"); Assert.notNull(exchange, "exchange cannot be null"); return exchange.getSession() .doOnSuccess(session -> { Map<String, OAuth2AuthorizedClient> authorizedClients = getAuthorizedClients(session); authorizedClients.put(authorizedClient.getClientRegistration().getRegistrationId(), authorizedClient); session.getAttributes().put(this.sessionAttributeName, authorizedClients); }) .then(Mono.empty()); }