If you want to control who can and who can't join your server, you can configure a whitelist on your server. The whitelist is a list of players that are allowed to join your server. If the whitelist is enabled and someone who's not on the whitelist tries to join, they will be disconnected.
In newer versions of the Bedrock Edition, the whitelist is called allowlist. It works the exact same way and just has a new name.
Setting up the whitelist
You first need to enable the whitelist in the options:
And then you need to add players to it in the 'players' section by typing your name and then clicking the add button:
Adding a Bedrock Edition player with Geyser
If you are using the Geyser plugin to allow Bedrock Edition players to join your Java Edition server, and you want to whitelist a Bedrock player, add '.' as the Geyser prefix in front of their name like this:
Enforce whitelist (Java Edition only)
If enforce whitelist is enabled in the server.properties, then players that are not on the whitelist will be kicked as soon as you turn the whitelist on or remove them from it.
Whitelists and cracked servers
On a cracked server, it's very easy for attackers to pretend they are you. They just need to change the username in their launcher to your name, and then they can bypass the whitelist. To prevent this, make sure you have a login plugin like OpeNLogin installed and set up. You can read more about how to install plugins here.