il.bert
il.bert

Reputation: 232

allow requests to gae endpoint only from a specific domain

Is it possibile to allow requests to a gae endpoint method only from a specific domain (e.g. www.myname.com) and refuse everything else?

I'm looking for something like an app authentication (I don't want a user login)

many thanks

Upvotes: 0

Views: 189

Answers (1)

Romin
Romin

Reputation: 8806

You could try out the following approach:

Inject the HTTPServletRequest parameter into your APIMethod.

@ApiMethod(path = "resources/{id}")

public Resource get(@Named("id") int id, HttpServletRequest request) {

//Use the request parameter here...

}

From the request parameter above, use the following:

String host = request.getRemoteHost(); 

Keep in mind that the host value can be your client or proxy's host name.

Upvotes: 1

Related Questions