#How to allow access to endpoint only from a specific client?

1 messages · Page 1 of 1 (latest)

half flax
#

Hello. I recently started learning Spring Boot and decided to write a small project. It's a small "banking" application (if I can say so) for my Minecraft server.
But when it came to registering... I don't know how to implement it properly. The point is that I want '/api/auth/register' to be accessed ONLY by the plugin on the Minecraft server. So that when some user tries to send a request, let's say via postman, an error is returned.

echo egretBOT
#

This post has been reserved for your question.

Hey @half flax! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

mental coyote
#

You could set up authorization tokens that are manually created as part of an administrating process for validation from incoming requests, or host the application on the same machine, potentially even widen the scope to the same network.

half flax
mental coyote
#

You merely check the provided address, yes. About the token suggestion - you set up an authorization (considering your use case, mere universally unique identifiers would do) system, a rather simple one. For each request sent to the server you provide a token (perhaps present in a configuration somewhere in the directory of your Minecraft server, a plugin or similar) however you wish, you then validate it against existing ones in a database of sorts and ensure its authenticity.

#

You don't really need to set up a way to create the tokens externally, but could rather do so manually via database access if it's not a token that is periodically updated and then use that token from your Minecraft server whenever the requests are sent.

#

Rough example in visual theory;

Database table
  tokens
    value CHAR(36)

Application
  endpoint
    incoming_token = header(AUTH-TOKEN)
    if incoming_token !in table.tokens.value
      deny
    continue

Minecraft
  config.token = 123e4567-e89b-12d3-a456-426655440000
  send_request = header(AUTH-TOKEN = config.token)
#

@half flax does this make any sort of sense? 🤣

half flax
echo egretBOT
# half flax Well, yeah 🤣 . Thanks you!

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.