Coder Social home page Coder Social logo

personium / personium-engine Goto Github PK

View Code? Open in Web Editor NEW
16.0 8.0 7.0 2.4 MB

Additional module for personium-core to enable server-side JavaScript execution.

License: Apache License 2.0

Java 55.28% JavaScript 44.45% Shell 0.07% Dockerfile 0.21%
personium personium-engine javascript

personium-engine's Introduction

Personium Engine

Additional module for personium-core to enable server-side JavaScript execution.

Documentation

http://personium.io/docs/

Requirements

The component personium-engine works behind of personium-core component. So, you have to launch personium-core and need backends, then you have to configure personium-core to use personium-engine you launched.

Please refer to personium/ansible to prepare them manually.

Launch

There are two options to launch personium-engine. DO NOT make the engine endpoints public. personium-engine is designed to run behind the personium-core.

Using war file

You can use maven to build personium-engine.war file to run on a servlet container.

git clone https://github.com/personium/personium-engine
cd personium-engine
mvn package

After compiling, you can get war file on target folder. ( target/personium-engine.war )

Using docker image

You can build docker container image including personium-engine based on Tomcat image with below command.

docker build . -t personium-engine

After building, you can launch personium-engine in docker container.

docker run -d -p 8080:8080 personium-engine

You can mount volume to use specified configuration.

docker run -d -p 8080:8080 -v /path/to/config.properties:/personium/personium-engine/conf/personium-unit-config.properties personium-engine

Testing

  1. Place personium-ex-mailsender jar file and Ext_MailSender.properties file in /personium/personium-engine/extensions. Content of Ext_MailSender.properties is below.

    io.personium.engine.extension.MailSender.smtp.host=localhost
    io.personium.engine.extension.MailSender.smtp.port=1025
  2. Launch required software with docker-compose up

  3. Launch personium-core on Tomcat9 locally.
    For example, with below comand. ( Set $TOMCAT_DIR environment value to path of directory which Tomcat9 installed, and place personium-core.war on $TOMCAT_DIR/webapps/personium-core.war. )

    JAVA_OPTS="-Djava.util.logging.config.file=$TOMCAT_DIR/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dcatalina.base=$TOMCAT_DIR -Dcatalina.home=$TOMCAT_DIR -Djava.io.tmpdir=$TOMCAT_DIR/temp -Dio.personium.configurationFile=$PWD/src/test/resources/personium-core-unit-config.properties" catalina.sh run
    
  4. Execute tests with maven.

    mvn -f pom.xml test
    

License

Personium is licensed under the Apache License, Version 2.0. See LICENSE.txt

personium-engine's People

Contributors

dependabot[bot] avatar hideakikondo avatar hiroaki-shibata avatar nisiguti avatar personiumio avatar sawamiwataru avatar shimono avatar tochi-y avatar yoh1496 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

personium-engine's Issues

Remove unnecessary properties.

Delete unnecessary items from personium-unit-config-default.properties.

# elasticsearch configurations
io.personium.core.es.hosts=localhost:9300
io.personium.core.es.cluster.name=clusterpersonium
io.personium.core.es.unitPrefix=u0

_p.localbox support

Make boxlocal file operations and OData operations simple.

Add the followings to personium-dao.js.

_p.localbox =  function() {
    try {
        return _p.as('client').cell().box();
    } catch (e) {
        return null;
    };
};

Sample in engine script:

_p.localbox().col('dir1')

Wrong class name

Box

There is no way to get the box name and schema URL in engine script. The following is the suggested modification.

image

Engine returns timeout immediately

The code below is executed correctly.

function(request) {
  var Context = org.mozilla.javascript.Context,
  currentContext = Context.getCurrentContext,
  rhinoVersion = currentContext.getImplementationVersion;

  return personium.createResponse(200, rhinoVersion );
};

var _ = require("underscore")._;
var personium = require('personium').personium;
var console = require('console').console;

And the engine returns Timeout , but it doesn't take as long as a few seconds.

Is this correct ?

Engine Timeout

After parsing the CSV file, the operations of adding 10000 entries to DB has triggered the Script Timeout Error .

If we cannot set Timeout value dynamically, then maybe we have to find a way to execute time consuming script offline. (AJAX like function in the Engine)

Introduce "_p.asEngine()" method to return an accessor with preset "__engine" accoount and role

Overview

Introduce a new accessor creation method "asEngine()" in the engine library and make
the following code return an accessor with pseudo role "../__/__engine" and pseudo account "__engine"

  _p.asEngine().cell().

Token spec

Engine should then return an access token with the following spec:

Role Subject
box/_engine {CellURL}#__engine
../__/_engine {CellURL}#__engine

With these modifications, box install alone can enable engine to access any box-local resource by distributing ACL to grant "__engine" to access that resource.

Related Core modification

personium/personium-core#431

considerations.

  • Is it necessary to accept pseudo-account "__engine" as a "serviceSubject" attribute in the ESC (Engine Service Collection) setting?
  • Do we need another pseudo-role, pseudo-account "__rule" for event-rule-triggered execution of engine script?

301 Redirect is needed for OAuth 2.0 support

In order to support OAuth 2.0, we need to redirect from App Cell to Google Authorization Server.
Currently 302 will not work properly. Must use 301 to move to the server completely.

Tests do not work properly.

Engine Tests are too complicated to run since Engine is supposed to be called from core and again call core .. We probably need to organize and refactor the tests.

CSV parser support

It would be nice to use a library like this to support parsing and exporting of CSV file within the Engine Script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.