FAQ

Security Agent

Published: May 19, 2020
Edited: May 21, 2020

Security Agent Plugin

Version: 1.0

Status:

SecurityAgent plugin for Thunder framework.

Table of Contents

Introduction

Scope

This document describes purpose and functionality of the SecurityAgent plugin. It includes detailed specification of its configuration and methods provided.

Case Sensitivity

All identifiers on the interface described in this document are case-sensitive. Thus, unless stated otherwise, all keywords, entities, properties, relations and actions should be treated as such.

Acronyms, Abbreviations and Terms

The table below provides and overview of acronyms used in this document and their definitions.

Acronym Description
API Application Programming Interface
HTTP Hypertext Transfer Protocol
JSON JavaScript Object Notation; a data interchange format
JSON-RPC A remote procedure call protocol encoded in JSON

The table below provides and overview of terms and abbreviations used in this document and their definitions.

Term Description
callsign The name given to an instance of a plugin. One plugin can be instantiated multiple times, but each instance the instance name, callsign, must be unique.

References

Ref ID Description
HTTP HTTP specification
JSON-RPC JSON-RPC 2.0 specification
JSON JSON specification
Thunder Thunder API Reference

Description

Security Agent of thunder is responsible to allow or block access to the Thunder API.

The plugin is designed to be loaded and executed within the Thunder framework. For more information about the framework refer to [Thunder].

Configuration

The table below lists configuration options of the plugin.

Name Type Description
callsign string Plugin instance name (default: SecurityAgent)
classname string Class name: SecurityAgent
locator string Library name: libWPEFrameworkSecurityAgent.so
autostart boolean Determines if the plugin is to be started automatically along with the framework

Methods

The following methods are provided by the SecurityAgent plugin:

SecurityAgent interface methods:

Method Description
createtoken Creates Token
validate Validates Token

createtoken method

Creates Token.

Description

Create a signed JsonWeb token from provided payload.

Parameters

Name Type Description
params object
params?.url string (optional) Url of application origin
params?.user string (optional) Username
params?.hash string (optional) Random hash

Result

Name Type Description
result object
result.token string Signed JsonWeb token

Errors

Code Message Description
1 ERROR_GENERAL Token creation failed

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "SecurityAgent.1.createtoken",
    "params": {
        "url": "https://test.comcast.com",
        "user": "Test",
        "hash": "1CLYex47SY"
    }
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICAgImpzb25ycGMiOiAiMi4wIiwgCiAgICAiaWQiOiAxMjM0NTY3ODkwLCAKICAgICJtZXRob2QiOiAiQ29udHJvbGxlci4xLmFjdGl2YXRlIiwgCiAgICAicGFyYW1zIjogewogICAgICAgICJjYWxsc2lnbiI6ICJTZWN1cml0eUFnZW50IgogICAgfQp9.lL40nTwRyBvMwiglZhl5_rB8ycY1uhAJRFx9pGATMRQ"
    }
}

validate method

Validates Token.

Description

Checks whether the token is valid and properly signed.

Parameters

Name Type Description
params object
params.token string Token that will be validated

Result

Name Type Description
result object
result.valid boolean Tells whether token is signature is correct

Errors

Code Message Description

Example

Request

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "method": "SecurityAgent.1.validate",
    "params": {
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ewogICAgImpzb25ycGMiOiAiMi4wIiwgCiAgICAiaWQiOiAxMjM0NTY3ODkwLCAKICAgICJtZXRob2QiOiAiQ29udHJvbGxlci4xLmFjdGl2YXRlIiwgCiAgICAicGFyYW1zIjogewogICAgICAgICJjYWxsc2lnbiI6ICJTZWN1cml0eUFnZW50IgogICAgfQp9.lL40nTwRyBvMwiglZhl5_rB8ycY1uhAJRFx9pGATMRQ"
    }
}

Response

{
    "jsonrpc": "2.0",
    "id": 1234567890,
    "result": {
        "valid": false
    }
}
PHP Code Snippets Powered By : XYZScripts.com