#1 Re: mORMot 2 » mORMot2 + JavaScript client » 2023-08-26 10:51:18

igors233 wrote:

...
Do you know what kind of compiler EWB uses, is it a proprietary or DWScript?
For me UI and html controls are not important, I've did it for years and it's hard to maintain or change. What I'm doing now is create UI in html with mustache template and bootstrap and so UI can be changed by others (designer) and I just focus on code side.

Understood Igor.
Had a search through the EWB docs but cant find out which transpiler it's using.

This might be worth a look though (I haven't studied it in any detail yet) :
    https://quartexdeveloper.com/
You'll be familiar with the author. The payment system looks kind of strange though.

#2 Re: mORMot 2 » mORMot2 + JavaScript client » 2023-08-25 11:20:02

igors233 wrote:

I'll be starting a new webbased application and idea is to use mormot mvc app for serverside with Mustache templates for UI and javascript for client side.

Main question is what others use for client side java script development? Ideally I would like to write pascal code that's compiled to JS.
...


I closely examined most of the Pascal related web development applications over a number of years, and for me the standout solution was Elevate Web Builder both because of it's excellent architecture, delphi like IDE and form designer, and excellent visual controls.

So it's well worth a look (and it's very reasonably priced).

Let me know if you need further info (I've been using it as a mORMot client for some years now).

#3 mORMot 1 » Problems creating a new TSQLAuthGroup entry » 2021-01-18 06:32:56

Horbs
Replies: 0

Dear List
  I have a requirement to allow potential Customers to register in order to gain User access to the mORMot Server.
  The Server uses the Service Oriented Architecture and SQLite.
  I thought of doing this as follows.
      1. Create a TSQLApplicant table that contains Customer Contact information for the "Applicant" (the person wishing to register).
      2. Allow the Applicant to submit their details from the "Client" using a SQLAuthUser login "Applicant".
      3. Alter the SQLAuthGroup to ensure that user "Applicant" only has WRITE Access to the TSQLApplicant table - and no other tables. (The Admin staff will view the Applicant records on a daily basis and  "register" (create a User login) for those Applicants who are approved.
  My test Server defines "RSvrDB.ServiceDefine(TServiceApplicant, [IUsrApplicant], sicShared);", which only contains one method - that being to create a new TSQLApplicant record.
  Security is enabled via "TSQLRestServerAuthenticationDefault".
  I've used the following code to update the TSQLAuthGroup table :
 
  ...
  begin
  tblIndex :=  Model.GetTableIndex(TSQLApplicant);
  AuthGrp := TSQLAuthGroup.Create(RSvrDB, 'Ident = ?', ['Applicant']);
    C := True; R := False; U := False; D := False; //Only Create enabled
    AuthGrp.Ident := 'Applicant';
    AuthGrp.SessionTimeout := 60;
    rights := AuthGrp.SQLAccessRights;
    rights.Edit(tblIndex, C, R, U, D);
    rights.AllowRemoteExecute := [reService];
    AuthGrp.SQLAccessRights := rights;
    grpID := RSvrDB.AddOrUpdate(AuthGrp, True);   //   .Add(AuthGrp);
    ...
    goes on to register the AuthUser "Applicant" login.
   
The AuthGroup now contains the value "2,0,3,0,0,0" for AccessRights.
(GetTableIndex(TSQLApplicant) returns an Index of 3).
And, the AuthUser entry for "Applicant" has the value 5 in the GroupRights column, which is the TID value for the "Applicant" AuthGroup entry.

But, when I log in to the Client as "Applicant", I'm not prevented from performing ALL the CRUD operations on all the tables, and I can perform all CRUD operations on Applicant (not just "Create", so the new AuthGroup setting seems to have no effect).
I've spent of lot of time reading the SAD 1.18 PDF and searching the Forum, but I just can't figure out what I'm doing wrong (going nuts).

So, I guess I have two questions :
  1. Is my approach to this requirement appropriate?
and
  2. If Yes, could someone point me to an example of how to perform this task? (None of the mORMot examples seem to do this)
 
Many thanks All. ANY advice would be deeply appreciated.

Horbs

#4 Re: mORMot 1 » How to hook an Authentication event on the Server. » 2020-12-18 10:17:10

Yes, I am already using Interface based Services.

OnSessionCreate looks good and will give me some of what I need (Session User Info). I will also  need to add some other variables derived from User Requests over the life of the User Session.

  "You define an interface, on server side you register a class that implements that interface, setting instance lifetime to sicPerSession. Now you can store user variables in that object
  instance which is available for the lifetime of the user session."

Not sure how to implement this. I'm thinking that I'll need to create some form of simple storage construct - maybe an in memory TSQLTable instance for the life of the User Session.
Problem is that it can't be created until after OnSessionCreate is invoked (but maybe I can instantiate it within the OnSessionCreate function).
Also, I don't know yet how to get one interface method to call another interface method on the server side (I'm assuming I'd need to invoke the sicPerSession method from within OnSessionCreate).

I'll have a play during the next few days and see what I can come up with.

Many thanks pvn0

Horbs

#5 mORMot 1 » How to hook an Authentication event on the Server. » 2020-12-16 11:58:01

Horbs
Replies: 3

I need to store some user variables for the life of a Server User Session.
These vars will be used to populate some records in Interface Service requests throughout the user session life cycle.
What I'd like to achieve is to identify some kind of event that gets triggered by mORMot after a successful authentication, and be able to hook that event from my code. I'd then want to store that info (User TID and AuthGroup etc) for the life of that User Session in a way that's accessible to Service Requests (I'm thinking of SessionGetUser to retrieve the info, but knowing how to and what to hook has me stumped).

Can anyone suggest a way to automatically capture the result of the authentication process so that I can fire off a method to store the required user info?

Many thanks

Horbs

#6 mORMot 1 » Security and Client use of TSQLRecord User ID's » 2020-05-25 10:50:52

Horbs
Replies: 2

I have a public facing mORMot Interface based Server running TSQLRestServerAuthenticationDefault with a SQLite database, accessed by a JavaScript Client.

The OneToMany database structure uses the TSQLUser TID as the table identifier for the "Customer" (top most) table (which derives it's primary key from TSQLAuthUser), which is propagated to some detail tables as the foreign key. And the authenticated User should only have access to those records that match (directly or via a foreign key) the TSQLUser TID hierarchy.

Because of the ASYNC nature of the architecture, it means that I have to pass the TSQLUserID to the client, and persist it there, for further Detail Table reads and updates (different Interface requests).

I'm thinking this may pose something of a security risk. I only want the authenticated user to have access to the records they own (via the relational hierarchy).

Am I being paranoid (I don't have a lot of in depth experience with this architecture).

If not being paranoid, is there some way I can create persistent Session Variables (Parameters) SERVER SIDE to hold the primary and surrogate keys and populate them at run time for each Service request for the authenticated user session? (I've looked at ServiceContext, but it may be expensive to access that for each CRUD operation, may not be easily implementable for all surrogate keys, and could get messy).

Any thoughts or suggestions would be VERY welcome.

Maybe I'm just getting dumber (too long in lockdown).

Thanks All

Horbs

#7 mORMot 1 » Reading values from TSQLAccessRights » 2020-03-06 11:55:31

Horbs
Replies: 0

I have a requirement that asks me to provide a user interface which allows (non technical) administrator staff to administer the User and Group tables (using SOA + SQLite). Ideally, I'd like to return the AccessRights in a grid with human readable values for the users to digest.
Is there any way I can return the bitfield results from GetSQLValues or GetAccessRights in a format where I can populate fields for each of the AccessRights values into columns (POSTSQL|SELECTSQL|Service|AuthR|AuthW|TablesR|TablesW) - perhaps as boolean values to populate check boxes, or Yes|No values?

And a couple of minor things :
1. The mormot Framework SAD describes security group layout as POST SQL SELECT SQL Auth R Auth W Tables R Tables W Services
Notes in mORMot.pas show                                                         POSTSQL SELECTSQL Service AuthR AuthW TablesR TablesW
** Note the position of "Service" (I'm assuming the mORMot.pas sequence is correct).
2. For "Admin" we have "VALUES ('Admin',10,'47,1-256,0,1-256,0,1-256,0,1-256,0')". I'm confused by the ",0," values. Are they just field separators ?

#8 Re: mORMot 1 » VirtualTableExternalRegisterAll and Auth Tables - SQLite » 2019-06-04 06:14:52

Thank you AB - that fixed it.

But still had a problem in that the Auth tables were empty.

Fixed by moving "Model := CreateSampleModel;" to the first line.

Horbs

#9 mORMot 1 » VirtualTableExternalRegisterAll and Auth Tables - SQLite » 2019-06-02 10:23:22

Horbs
Replies: 2

I'm currently implimenting Buisness Administration functionality to an almost completed Booking System project using mORMot and SQLite.

The Client uses a web javascript front end, and the Admin functions will be provided by a Delphi VCL Client (doing that now). I've just started to impliment User Management, and I'm confused regarding errors with the TSQLAuthGroup, TSQLAuthUser tables with respect to VirtualTableExternal and CreateMissingTables.

The server side code is :

  {1}  DBProps := TSQLDBSQLite3ConnectionProperties.Create('PopitBookings.DB3','','','');
  {2}  Model := CreateSampleModel;
  {3}  VirtualTableExternalRegisterAll(Model, DBProps);
  {4}  PopitDB := TSQLRestServerDB.Create(Model, 'PopitBookings.db3', False);
  {5}  PopitDB.CreateMissingTables; // error here
  ...

Prior to implementing the Auth tables, I could delete the Bookings.db3 file and, on running the server, a new database was created as expected.

After adding the Auth Tables - Model Creation is now :

  TSQLModel.Create([TSQLAuthGroup, TSQLAuthUser, and the other 7 tables ... ]);

And now I get an exception after Line 5 (CreateMissingTables) that tells me the Database is busy :
  "Error SQLITE_BUSY using 3.28.0 - database is locked ...".

If I omitt line 3, the Auth tables are created as part of the database, but not populated wit Auth records.

I've read the SAD over and over, but have had no success in figuring out how to resolve this issue, or understanding why my approach is wrong.

Any help/advice would be greatly appreciated (mORMot version : 1.18.5232).

#12 Re: mORMot 1 » CreateAndFillPrepare like Queries on the Server Side » 2018-12-07 09:51:47

Oh - should have said - using standard SQLite Server - TSQLModel.

#13 Re: mORMot 1 » CreateAndFillPrepare like Queries on the Server Side » 2018-12-07 09:38:40

Thanks ab.

For generating the query, what technique should I use. I'm guessing SQL is not an ideal option.

Cheers

Horbs

#14 mORMot 1 » CreateAndFillPrepare like Queries on the Server Side » 2018-12-07 09:04:43

Horbs
Replies: 6

I'm currently dveloping a WEB based client/mORMot server solution, and don't seem to have any options for generating CreateAndFillPrepare type queries on the Client side.

The current requirement is to return one or more detail table result sets to the Client based on the master table's primary key (and also limit the result set where a detail field table field matches some parameter). I'd prefer not to use SQL if possible.

I'm thinking along the lines of some kind of remote procedure call from the Client, and I'd really like to keep as much of the ORM functionality as possible.

One important constraint is that the HTTPServer will need to also support a standard Delphi client performing CreateAndFilPrepare statements against TSQL tables.

Can anyonee point me in the right direction for solving this problem?

Many thanks

Horbs

#15 Re: mORMot 1 » mORMot and Elevate Web Builder » 2018-11-24 06:55:38

This is a resopnse to emk's post.

emk, it would be really, really usefull if you could post some guidance on getting started with EWB - making requests to the mORMot ORM.

Some people may need functionality (specific Use Cases) that Erick's solution doesn't support - and some may wish to expand Erick's library with new features for their own special requirements, and some guidance on using the "native" EWB features to access a mORMot Server would be really usefull.

Maybe, just to start with - just some points on how to begin - just some instructions to get people started rather than (for now) code examples.

I wish there was somewhere that interested parties could discuss and collaborate - anyone have any ideas ? If we can raise the profile of this kind of solution it should benifit both mORMot and EWB.

Cheers

Horbs

#16 Re: mORMot 1 » Filling a grid in Elevate Web Builder » 2018-11-21 01:42:05

Just some further information to describle what I've done.

The mormot server is pretty standard :

procedure TfrmMain.FormCreate(Sender: TObject);
begin
  Model := CreateSampleModel;
  DB := TSQLRestServerDB.Create(Model, 'PopitBookings.db3', False);
  DB.CreateMissingTables;
  Server := TSQLHttpServer.Create('8080',[DB],'+',HTTP_DEFAULT_MODE);
  Server.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
end;

On the EWB Side I've refactored Sample1 as follows

Replaced the 'Fish" mormot table with my Customer table definition.

Replaced all instances of Fish with Customer.

Define the DataSet1 fields as per the "Customer" table.

Modified and added the Grid columns as per the Customer table.

Added a MultiLineEdit control to the form for debugging.

In the ewbmormot  procedure TForm1.OnPopulate( s : string ); method I have :

  MultiLineEdit1.Lines.Add(s);
  DataSet1.Open;
  DataSet1.LoadRows( s );


Now when I run the client, I get "Expected "{", instead found } at 0"

and the MultiLineEdit shows "}"

I've tested the server operations with a Delphi VCL Client (using SynReatDatasets in a one to many configuration) and I can perform all CRUD operations against all 5 tables - so I just can't figure what's wrong on the EWB side - Erick's Sample1 program works fine on my machine using the Sample18 server and "Fish" tables.

Thanks

Horbs

#17 Re: mORMot 1 » mORMot and Elevate Web Builder » 2018-11-20 10:00:32

Thanks AB - that's great news. I'll let Erick know. Many thanks.

Edwin - agree with you :-)

#18 mORMot 1 » Filling a grid in Elevate Web Builder » 2018-11-20 01:01:38

Horbs
Replies: 2

This question might only be relevant to those who have used Ericks sample code (in his two Elevate Web Builder and mORMot books).

Background ...
I've started my first mORMot / EWB project and decided to begin by refactoring Example1.wbp from Erick Engelke's books, which fills a EWB Dataset via a request to the mORMot server (Server18 mORMot sample in Erick's source code). Ericks example runs fine on my machine. The sample I refactored (to use my SQLite database) failed ( opening bracket "{" was missing from the response being sent to the fill method).

Now I've tested the mORMot server using a Delphi VCL Client I wrote - and all CRUD operations work fine using the delphi client so I'm pretty sure the problem doesn't lie with the Server end.

I then tried Ericks example 2, and refactored it for my Server. I'm able to do CRUD operations on single records, but once again this sample fails when I try to add code to fill a EWB Client Dataset.

There are 2 diferent versions of the wrapper that I have tried (ewbmormot.wbs) - one is 123 kb, the other is 104 kb. The 104 k version does nothing (no errors that I've been able to trap, and an empty dataset after the operation), the 123 k version gives me the missing opening bracket error.

So my question is ....

Has anyone else tried what I'm attempting and found the same problem - and a solution ?

PS : Erick is working on a new version of his ewbmormot.wbs - but for now I'm really late on delivery of this project so any advice would be greatly appreciated. The problem is unlikely to lie in Erick's wrapper - but of my understanding as to how it works (I'm really struggling to get my head around it).

Thanks

Horbs

#19 mORMot 1 » mORMot and Elevate Web Builder » 2018-11-19 23:41:03

Horbs
Replies: 8

Just been working on my first mORMot / Elevate Web Builder application - started a few weeks ago and I'm having all kinds of problems.

My first question is for Arnaud, I'll post the second question as a seperate request.

I've noticed that the mORMot source hosts 2 wrappers (Mustache and Smart Mobile Studio) for accessing mORMot servers as part of the mORMot library, and I'm wondering if we could add one for EWB (Elevate Web Builder).

Erick Engelke has opensourced his mORMot wrapper (as sample code provided with his two EWB/mORMot books), and that would be a really good place to start in terms of collaboration to make best use of these two excellent frameworks.

Arnaud, can you advise whether you think this would be a worthwhile innitiative? If yes, I'll check with Erick to identify the most suitable version of his source code to include as a part of mORMot.

Horbs

#20 Re: mORMot 1 » TSynRestDataset Search Values » 2018-05-05 12:58:36

WOW - cheers AB - double quotes fixed it.

I'll check out the UrlEncode() part.

Huge thanks

Horbs

#21 mORMot 1 » TSynRestDataset Search Values » 2018-05-05 12:06:07

Horbs
Replies: 2

Dear All

This is a quick question on using "select by value" statements for the SynRestDataset.CommandText statements.

I've used ...mORMot\SQLite3\Samples\ThirdPartyDemos\EMartin\TSynRestDataset\FishFactSyn for this example.

If I modify
    'http://LocalHost:8080/root/BioLife?select=Species_No, ... ,Notes,Som&sort=Species_No,
by appending
    &where=Species_No=90110'
then the correct result set is returned.

But when I use
    &where=Category=Shark'
in place of the above I get ...

Error Not Found from ... where=Category=Shark.

Is there some special search formating / string literal that I'm missing?

Many thanks

Horbs

Board footer

Powered by FluxBB