Skip to content

Commit

Permalink
Inform admins when new oauth2 account is created using spring rabbit
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanehcine committed Sep 13, 2023
1 parent af3ed2d commit c4e07c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(GatewayAutoConfiguration.class)
@ImportResource({ "classpath:rabbit-listener-context.xml", "classpath:rabbit-sender-context.xml" })
@ConditionalOnExpression("${georchestra.gateway.security.createNonExistingUsersInLDAP:true}")
@ConditionalOnExpression("${georchestra.gateway.security.enableRabbitmqEvents:true}")
public class RabbitmqEventsAutoConfiguration {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class LdapConfigProperties implements Validator {

private boolean createNonExistingUsersInLDAP = true;

private boolean enableRabbitmqEvents = true;

@Valid
private Map<String, Server> ldap = Map.of();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,11 @@ public class OpenIdConnectUserMapper extends OAuth2UserMapper {
accountDao.insert(newAccount);
roleDao.addUser(Role.USER, newAccount);
userOpt = usersApi.findByOAuth2ProviderId(oAuth2ProviderId);
eventsSender.sendNewOAuthAccountMessage(oidcUser.getGivenName() + " " + oidcUser.getFamilyName(),
oidcUser.getEmail(), token.getAuthorizedClientRegistrationId());
if (config.isEnableRabbitmqEvents()) {
eventsSender.sendNewOAuthAccountMessage(
oidcUser.getGivenName() + " " + oidcUser.getFamilyName(), oidcUser.getEmail(),
token.getAuthorizedClientRegistrationId());
}
} catch (DuplicatedUidException e) {
throw new IllegalStateException(e);
} catch (DuplicatedEmailException e) {
Expand Down

0 comments on commit c4e07c5

Please sign in to comment.