Skip to content

Instantly share code, notes, and snippets.

@baso53
Last active November 13, 2021 21:42
Show Gist options
  • Save baso53/fed6acfc4bdf1ac2f0382b77411ec494 to your computer and use it in GitHub Desktop.
Save baso53/fed6acfc4bdf1ac2f0382b77411ec494 to your computer and use it in GitHub Desktop.
@Service
@RequiredArgsConstructor
public class UserManagementService {
private final FirebaseAuth firebaseAuth;
public void setUserClaims(String uid, List<Permission> requestedPermissions) throws FirebaseAuthException {
List<String> permissions = requestedPermissions
.stream()
.map(Enum::toString)
.collect(Collectors.toList());
Map<String, Object> claims = Map.of("custom_claims", permissions);
firebaseAuth.setCustomUserClaims(uid, claims);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment