question

praveen avatar image
praveen asked

Integrating PlayFab authentication with ASP.NET Core Authentication?

My game server is ASP.NET core server. I am also using SignalR.

ASP.NET core supports several external authentication providers. But I did not find any support for PlayFab. Is there an elegant way to integrate PlayFab authentication with ASP.NET core authentication?

I know that I can manually validate each client request on server side using server API.

https://docs.microsoft.com/en-us/rest/api/playfab/server/authentication/AuthenticateSessionTicket

But to do this for each and every request made by client, does not look idiomatic.

Authentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Rick Chen avatar image
Rick Chen answered

In order to reduce the AuthenticateSessionTicket API calls for client requests, you could cache the Session Ticket in your server after validating a new client. Then for the following requests, you just need to check if the session ticket is in the cache of your server. For example, you could implement the following logic when there is client request:

  1. Check if the client session ticket is in the cache and whether it is expired.
  2. If the session ticket is not expired, go ahead to execute the client request.
  3. If there is no such session ticket, use the AuthenticateSessionTicket to validate the ticket and put the session ticket into cache with expiration time = LastLogin time in the validation result + 24 hours.
  4. If the session ticket is expired, ask the client to provide a new session ticket.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

praveen avatar image
praveen answered

Okay, thank you. That is a much better approach.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.