question

Jon avatar image
Jon asked

Restrict access to certain cloudscripts

What is the best way to restrict client from calling certain cloudscript functions?

For example certain events are only meant to be triggered from playstream events or maybe a rule triggers it.

Thanks

10 |1200

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

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Setting PlayFab API policy can prevent clients from calling API ExecuteCloudScript, but PlayFab Policy doesn’t supports restrict access to the specific CloudScript function. When CloudScript function is triggered by a PlayStreamEvent, the info of this PlayStreamEvent would be contained in the context. So you can make conditional judgments in the function to limit the execution of valid logic. You can refer to the following testing CloudScript function.

handlers.handlePlayStreamEventAndProfile = function (args, context) {
    var psEvent = context.playStreamEvent;
    if (psEvent != null) {
        // use the specific event name
        if (psEvent.EventName == "player_logged_in") {
            //do something
            return { result: "executed the function" };
        } else { return { result: "nothing happened" }; }

    } else { return { result: "nothing happened" }; }

};
1 comment
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.