0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Publisher】Thinking about invisible ways of tokens

Posted at

I will try to solve the problem of the token being visible left as an issue in the previous post 【Publisher】Try executing the scheduled task on Sharperlight instance B from Sharperlight instance A

Instead of triggering the scheduled task in client-side JavaScript, use the server-side method of triggering the scheduled task so that you don't have to use tokens on the client side.
To achieve that, I have another published report with a function defined to execute the scheduled task, and call it from the client-side JavaScript.
When the report is called, the functions defined in the report query are executed and triggering the task on the server side.
image.png

Preparing report for task launch

Create public reports that trigger tasks. When this report is called using the Sharperlight service, the query defined within it will be executed and the desired task will be triggered. Since this is the side that calls the task, it is created on the Sharperlight instance A side.
Launch Sharperlight Publisher.
Start creating a new published report with the New button.
Fill in the Code, Group and Title and start building your query with the Edit Query button.
image.png
Since we only need to execute a task, the query result only needs to be one row, so let's set the Product to System, the Table to User Accounts, and the Mode to the default value of CU.
image.png
Define task trigger using an expression for output item.
Define the Service Name, Token, and Task Name of Sharperlight instance B as constants in the Sharperlight system properties. Create trigger by referencing them.
Let's create it with 4 output items.
image.png
Service Name:
Get the service name of Sharperlight instance B defined in System Properties of Sharperlight instance A.
image.png
Task Name:
Defines the name of the task to be executed.
image.png
Token:
Get the token for Sharperlight instance B defined in System Properties of Sharperlight instance A.
image.png
Trigger:
Trigger of the task. Define the launch function by referencing the above items using control tags.
image.png
The trigger is now complete. you save. Running a query with the query preview feature actually kicks off the task. You can check the operation if you want.

Editting Validation Report

Now, let's edit the verification report created in the previous article (the token was completely exposed).
Instead of running the task launch function in JS, we just want to call the report created above to launch the task.
By doing so, the task launch function defined in the report's query for starting the task will work at the server side.
To do so, use the command DataSource of the Sharperlight service.
A report called using the 'DataSource' command will not be displayed as a normal report, but will instead execute the contained query and return the resulting data set in JSON format to the client side.
This time, it's OK if the defined query is executed on the server side, so the task will be started, and the returned query result will be ignored.
Change this part of the previous JS code.
image.png
This is what it looks like here. You can see that the DataSource command is used to call the report for launching the task.
image.png
Set this new code in the custom HTML option of the report for verification and save it.
image.png
image.png

Verification

Start the services of Sharperlight instances A and B.
View the validation report in your browser.
image.png
Open the definition of the Sharperlight scheduled task to be executed and keep the History tab visible.
image.png
Click the Execute Task button in the verification report. Now go to the history tab of the task and view the history with the Refresh icon.
Shows the history of tasks triggered by button clicks.
image.png
Try opening the debugger against the report for validation. You can't see the token this time.
image.png

Thank you.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?