#1 Re: mORMot 2 » Am I using JWT correctly? » 2025-04-05 14:16:17

It would be great to add a new authentication method.
Using IdemPChar() was suitable for uppercase and lowercase letters, but it differentiated between "." and "/".
To fix the problem, I used this code: StringReplace(Ctxt.Call^.Url,'.','/',[rfReplaceAll])
Unfortunately, I was unable to use TBinaryCookieGenerator.

#2 Re: mORMot 2 » Example project using Castle Game Engine and mORMot 2 » 2025-04-05 14:02:19

Hello Michalis,

I have been following Castle Game Engine for many years, but I have not used it yet.
It is a great work, I hope you succeed.
It's a good thing that you used MORMOT 2.

#4 Re: mORMot 2 » I want use ORM very much but MORMOT are some restrictions » 2025-03-17 07:46:37

JD wrote:

I don't know what database you use, but it is a simple ON DELETE RESTRICT in PostgreSQL. It throws up a 23503 foreign key violation error code. See https://www.postgresql.org/docs/current … aints.html. And the example you cited is even discussed on the page. yikes

JD

All relational databases operate this way and do not allow deletion. 
I said the reason for this is to provide a more appropriate message to the user. 
When the primary key of my table is registered in several other tables, I give the user more accurate and clearer information. 
Of course, everyone uses their own approach.

#5 mORMot 2 » Am I using JWT correctly? » 2025-03-17 07:41:06

Kabiri
Replies: 5

Hello dear @AB

I have a function for generating JWT tokens, one for validating them, and another for revoking them. 
I created a whitelist for URLs that don’t require authentication and a blacklist for tokens that haven’t expired but have been revoked. 
In the `OnBeforeURI` event, if the URL is in the whitelist, I skip token validation and let the request proceed. 
If the URL isn’t in the whitelist, I validate the token. If the token is valid and not in the blacklist, authentication is completed, and the corresponding method for that URL is executed. 
I did all this because I couldn’t find an automatic solution for this in mORMot2.

I have two questions: 
1. Is there no automatic solution for this, and do I have to handle it this way? 
2. My problem is with URLs that have slight variations — for example, `api/Auth.Login` and `api/Auth/Login` are both valid. Is there a way to avoid adding multiple similar URLs to the whitelist?

#6 Re: mORMot 2 » I want use ORM very much but MORMOT are some restrictions » 2025-03-15 18:47:02

@JD
It’s true that my work increases. 
Managing tables and dependencies becomes difficult and time-consuming, and development must be done carefully. 
However, in return, I can show more understandable messages to the end user. 

Imagine a software user wants to delete a product. 
I check the inventory table and inform them that the product cannot be deleted because it still exists in the inventory. 
Or I let them know that the product is part of a sales invoice and therefore cannot be deleted.

#7 mORMot 2 » ORM+SQLServer+Create Table » 2025-03-09 12:29:58

Kabiri
Replies: 1

Hello

I have created the ORM.
I have also established the connection to the SQL Server database.
I have created the database on the sql server(manully).
However, the CreateMissingTables() command does not create the tables.

  TMainRestServer = class(TRestServerFullMemory)
  private
    FConnectionPool: TSqlDBFireDacConnectionProperties;
    Model: TOrmModel;

and

  aServer := TMainRestServer.Create;
  aServer.Model:=TOrmModel.Create([TormUnits]);
  VirtualTableExternalRegister(aServer.Model,[TormUnits],aserver.FConnectionPool);
  HttpServer := TRestHttpServer.Create('8080', [aServer], '+', HTTP_DEFAULT_MODE,4 );
  HttpServer.AccessControlAllowOrigin := '*';
  aServer.Server.CreateMissingTables();

Which part did I do wrong?

#8 Re: mORMot 2 » I want use ORM very much but MORMOT are some restrictions » 2025-03-09 09:49:56

mrbar2000 wrote:

I think you don't understand what is being proposed in this thread. The proposal is for mormot to prevent a record from being removed from the database if the record is being used by some property of another object that references this table. this will to avoid inconsistency in the database or the table that references the deleted record being set to ZERO as mormot does today.

The issue of creating the FK is just something additional to prevent the programmer from using a delete outside the ORM from also leaving the database inconsistent.

I know what you're saying, but I still prefer to control the table dependencies myself. When I delete a value in one table and know it's used in another table (like master/detail tables, etc.), I use a select to make sure the record isn't being used in the related tables. The benefit of this method is that my API tells the user they cannot delete this record because it is being used in the (table name) table.

#9 Re: mORMot 2 » Where can I find a list of all mORMot 2 servers? » 2025-01-26 16:32:40

My data is stored in a cloud database. 
I was looking for a suitable server for this purpose, but I couldn't find a list of servers and explanations of how they work. 
Therefore, I chose TRestServerFullMemory.

#10 Re: mORMot 2 » Where can I find a list of all mORMot 2 servers? » 2025-01-22 21:37:50

ab wrote:

What do you call "a list of all servers"?

For example:
TRestHttpServer
TRestServerFullMemory
THttpProxyServer
TRestServerDB
TRestServer

#11 mORMot 2 » Where can I find a list of all mORMot 2 servers? » 2025-01-22 18:27:12

Kabiri
Replies: 3

Hi
Has documentation for mORMot 2 still not been created? 
Where can I find a list of all servers and their functionalities?

#12 Re: mORMot 2 » How can I disable server-side caching in THttpProxyServer ? » 2024-12-18 09:20:12

I apologize for my poor English.
I meant to set a filter (*.ls for all files with the .ls extension) for the IgnoreCsv value, but I think this property doesn't accept filters.(Because it didn't work)

#13 Re: mORMot 2 » How can I disable server-side caching in THttpProxyServer ? » 2024-12-17 14:59:39

Thanks
I used it like this: settings.MemCache.IgnoreCsv:='*.ls';
I don't think it works with filtering.

#14 Re: mORMot 2 » How can I disable server-side caching in THttpProxyServer ? » 2024-12-17 13:54:46

Thanks
When I download the content of a file, and then if the file's content changes, and I download the same file again, the file's content is still the old one. I have a file whose content is constantly changing. It would be great if I could tell the THttpProxyServer not to cache that file.

#15 mORMot 2 » How can I disable server-side caching in THttpProxyServer ? » 2024-12-17 12:47:12

Kabiri
Replies: 7

I've created a file server using THttpProxyServer.
When I first request the content of a URL-related folder, the correct response is returned. However, subsequent requests show the previous file list, even if the folder content has changed.
I suspect this is due to caching. I haven't found a way to disable it.

#16 Re: mORMot 2 » THttpProxyServer Inquiry » 2024-11-26 07:06:54

I used the `THttpProxyServer` server. 
There are about 100 files on the server, and I want to share them with authorized users. 
I want to create a unique URL for each task. 
When the program runs, those files should be accessible in Google Chrome through the URL provided to the user by the program (on the same system where the program is running). 
For this reason, I used `THttpProxyServer`. 
I don't know if `THttpServerGeneric.ReplaceRoute()` can be used with `THttpProxyServer` or not. 
I want to create an interface that adds a new route to the `THttpProxyServer` server and specifies which file this route corresponds to. Then, in the `OnBeforeBody` section, if the IP does not correspond to the URL, return a 404 error. 

1. I have created the `THttpProxyServer` server. 
2. I have completed the `OnBeforeBody` section to check the URL and IP. 
3. I need to create an interface to add or remove URLs in the `THttpProxyServer`.

#17 Re: mORMot 2 » THttpProxyServer Inquiry » 2024-11-24 13:38:09

Thanks @ab.
I used it(OnBeforeBody) to create the whitelist and work fine.

Do you have any suggestions for adding and removing routes after starting the server without stopping it? 
Since many methods of `THttpProxyUrl` are defined as `protected`, I cannot use them in my class. It seems I have to add a function for this in the `mormot.net.async` unit.

#18 Re: mORMot 2 » THttpProxyServer Inquiry » 2024-11-23 12:18:29

I couldn't find a solution to dynamically create a whitelist of IP addresses.

#19 Re: mORMot 2 » THttpProxyServer Inquiry » 2024-11-09 17:16:30

Thank you @zen010101
I just didn't understand about the whitelist.

#20 mORMot 2 » THttpProxyServer Inquiry » 2024-11-08 13:23:17

Kabiri
Replies: 9

Hello,
I'm working with a THttpProxyServer.
I know I can add directories to it before creating the server. (settings.AddFolder(folder, url);)
1)What I'd like to know is how to dynamically add directories and map them to URLs after the server has been created and started?
2)Additionally, does THttpProxyServer support an IP whitelist? If so, how can I modify this list after the server has started?

#21 Re: mORMot 2 » Where do I start? » 2024-09-07 12:39:49

Thank you, @Thomas.
I’m trying my best to read the answers carefully, but since English isn’t my native language, I don’t fully understand everything, and sometimes I even explain things poorly.
I apologize for that. I will try harder and ask fewer questions.

#22 Re: mORMot 2 » Where do I start? » 2024-09-07 07:03:13

Thanks, @igors233.
I’m using SQL Server 2008 for the database.
I’m also using JWT and username/password for authentication.
I have an existing API written with HORSE, and I wanted to rewrite it with mORMot.
Additionally, I want to use the ORM feature of the mORMot framework in this rewrite (I have prior experience using TMS Aurelius).
The first challenge for me was understanding the different servers in mORMot, as I wasn’t sure which server is for what.
The second challenge was connecting it to SQL Server.
I haven’t yet tried JWT and authentication.
Regarding the servers, I realized that when I use TRestServerDB, the user or client can easily access the tables. Authentication might prevent this access, but from what I’ve studied, it doesn’t seem to check the access details. For example, imagine I have a "status" field that marks records as deleted (without physically deleting them). In the method for listing data, I don’t send these records, but since the client has access to the table through ORM, they can retrieve those records.
Also, when I use TRestServerFullMemory, I no longer have access to the ORM.

#23 Re: mORMot 2 » Where do I start? » 2024-09-03 10:34:44

When I switch from TRestServerDB to TRestServerFullMemory, how do I access the database?
Do I have to abandon ORM in this case and revert to the old method of database access?

#24 Re: mORMot 2 » Where do I start? » 2024-09-02 11:10:28

I think I was a bit confused, but I understand now. smile

#25 Re: mORMot 2 » Where do I start? » 2024-08-31 13:20:29

No, I don't want to keep the tables in the original TRestServer model.

#26 Re: mORMot 2 » Where do I start? » 2024-08-31 12:42:09

You have run so many marmot tests and everything is clear to you. It's not that clear to me.
I've modified the server by setting

HttpServer := TRestHttpServer.Create(HttpPort, [], '+', useHttpApiRegisteringURI,4);

, but my Delphi client can no longer connect to it.
I reverted the previous command to its original state and made changes to the service.
I modified the class from 'TProductServer = class(TRestServerDB)' to 'TProductServer = class(TRestServer)'.
However, I'm getting an access violation error at the line 'ServiceDefine(TProductService, [IProductService], sicShared);'
I really don't know where to delete the model from the server.

#27 Re: mORMot 2 » Where do I start? » 2024-08-31 11:43:37

I've been unable to locate a solution to prevent direct access to the ORM.
It would be convenient if the server offered a method named AllowDirectAccess. :rolleyes

#28 Re: mORMot 2 » New AI assistant to help with mORMot » 2024-08-31 11:22:16

It was interesting talking to them, but it didn't help me.

#29 Re: mORMot 2 » Where do I start? » 2024-08-20 07:45:31

Kabiri wrote:

Thank you.
I changed the interface name.
It's giving the error:
Project TestServer.exe raised exception class EHttpApiServer with message 'HttpSetServiceConfiguration failed: ERROR_ACCESS_DENIED (5)'.
But the database and table are created. (I also added the command ProductServer.Server.CreateMissingTables;).

Is this error a known occurrence?
What steps should be taken to rectify this error?

---Edit
I have also successfully modified the list method.

Is this the right and proper way to do this?

function TProductService.List(var AProduct: TProductParam): RawJson;
var
  Sql: RawUtf8;
begin
  Sql := 'select * from Product';
  Result := TRestServerDB(Self.Server).DB.ExecuteJson(Sql, True);
end;

How do I disable ORM for the client?
Currently, there are commands like :
http://127.0.0.1:8080/root/Product
http://127.0.0.1:8080/root/Product/1
are returning records without any filtering or validation

#30 Re: mORMot 2 » I want use ORM very much but MORMOT are some restrictions » 2024-08-19 12:26:37

I use SQL but I never use foreign keys. I always manage table relationships myself. I think foreign keys are more of a hindrance.

#31 Re: mORMot 2 » Where do I start? » 2024-08-19 09:47:12

I think my way of categorizing units into Controller and DAC is not very suitable for Mormot.
I should choose a different structure for categorizing files in Mormot.
Do you categorize your files in a specific way?
My next question is how to implement the List method to return the list of desired records to the client?

Thanks

#32 Re: mORMot 2 » Where do I start? » 2024-08-18 17:58:54

Thank you.
I changed the interface name.
It's giving the error:
Project TestServer.exe raised exception class EHttpApiServer with message 'HttpSetServiceConfiguration failed: ERROR_ACCESS_DENIED (5)'.
But the database and table are created. (I also added the command ProductServer.Server.CreateMissingTables;).

#33 Re: mORMot 2 » Where do I start? » 2024-08-18 06:32:24

What is the reason for the following error?
Project TestServer.exe raised exception class EServiceException with message 'TServiceFactoryServer.Create: IProduct routing name is already used by a Product SQL table name'.

My test Project source
https://mega.nz/file/d5RTDB5A#f-mBchZj4 … a826ZtybbA

I haven't assigned the model to TRestHttpServer.Create yet, but the problem doesn't originate from there.

#34 Re: mORMot 2 » Where do I start? » 2024-08-17 11:33:35

I finished reading BeDelphi2014 today.
There are still some things that are unclear to me.
My first question is:
Has the syndb unit been removed from mormot2?

#35 Re: mORMot 2 » Where do I start? » 2024-08-14 11:50:10

In the examples, I only saw connections to SQLite. What should I do for MSSQLServer?
Which units should I add?
Previously, when accessing the database,
I created a connection and then closed it after retrieving the data. (In the events related to creating and destroying the class) And apparently here, when the server is running, the connection is created and remains open until the end of the server.

#36 Re: mORMot 2 » Where do I start? » 2024-08-13 17:40:27

Well, that's right. I hadn't thought about the FP.

#37 Re: mORMot 2 » Where do I start? » 2024-08-13 17:01:37

In the unit 'mormot.core.variants', the unit 'mormot.core.base' is called,
which in turn calls 'variants'. However, the IDE mistakenly identifies it as 'mormot.core.variants'.
While this is indeed an IDE error (Or an unintentional setting in the IDE) , the easiest way to prevent this is to use 'system.variants' instead.

#38 Re: mORMot 2 » Where do I start? » 2024-08-13 13:51:34

@ab
I downloaded the new version of mormot2 yesterday.
In the mormot.core.base unit at line 36, the unit variants should be changed to system.variants.
Because it's giving a Circular unit reference to 'variants' error.
(Delphi 12.1)

#39 Re: mORMot 2 » Where do I start? » 2024-08-12 16:42:45

Thank you. I will try it

#40 Re: mORMot 2 » Where do I start? » 2024-08-12 15:35:37

I'm not sure I understand correctly.
Do you mean I should write an application server on a server and have an API connect to it as a client, retrieve database information, and then act as a server itself to send the data to the client (user side)?

#41 Re: mORMot 2 » Where do I start? » 2024-08-12 14:58:01

Márcio Baroni wrote:

I've been using Mormot for a long time and it was really difficult at first.
If I can give one piece of advice, don't mix the ORM layer with the API layer.
Create ORM classes just to interact with the database.
Create another layer of classes (DTO) for your api or business rules...
With your DTO you can return whatever you want in your api without any relation to ORM, making it much cleaner.

Thank you for your explanation.
I generally prefer to keep the ORM and API layers separate. I'm not sure if this would cause a performance decrease.
I've been busy with other things for a while, but now I'm back to learning about Mormot. I want to create methods both with and without Models on a single server, and connect to it using a client.
I hope this isn't too difficult and I'm not bothering anyone.

#42 Re: mORMot 2 » Where do I start? » 2024-07-04 11:54:05

Thanks @ab
Thanks @edwinsn
Thanks @rdevine

I think I'll be busy with this for a few days.
The question that's on my mind is whether it's possible to have multiple ORM models, multiple JSON outputs from the database, and non-model methods in a single API.

#43 Re: mORMot 2 » Where do I start? » 2024-07-04 06:29:22

Thanks @edwinsn smile
I am determined to learn mormot2. I can use it with the help of examples, but I wanted to understand how it works. I have a lot of questions on my mind and I hope to find the answers soon.

It would be great if this forum had a "thanks" button for posts.

#44 Re: mORMot 2 » Where do I start? » 2024-07-04 06:22:53

lfyey121 wrote:

Orm model can have no objects;

I understand. So in any case, the model must be created, but the model can be empty and not contain any objects.
Thanks

#45 Re: mORMot 2 » Where do I start? » 2024-07-03 21:45:46

tbo wrote:

Why is this a problem?

With best regards
Thomas

That's not the problem.The problem is how to do it.

APIs can generate different types of outputs.
For example:

  • A method that simply returns a number as the API version.

  • A simple method (like ping) that returns a simple value (for testing connectivity).

  • Up to complex methods that return a record or records from a database.

  • Or even files or streams.

Therefore, an API needs to be able to access all types of methods.

#46 Re: mORMot 2 » Where do I start? » 2024-07-03 17:26:48

I reviewed the mormot2 examples. In the examples, everyone uses the model. sad

#47 Re: mORMot 2 » Where do I start? » 2024-07-03 07:20:38

I've looked through the v1 documentation as much as I can, but I'm still not sure how to connect to the TRestServerFullMemory server for communication on the client side when I'm not using a model and orm.
I used TRestHttpClient and set the model parameter to nil. But I get an accessviolation error in the ServiceDefine instruction.

#48 Re: mORMot 2 » Where do I start? » 2024-07-01 13:08:27

Thank you.  I fully understood how to use the interface without using orm.
I have a problem with the client. If I don't understand, I will ask.

#49 Re: mORMot 2 » Where do I start? » 2024-06-30 17:58:31

Thank you.
I have created a new record for the output, but the JSON output contains both the input record and the record I defined for the output. What can I do to prevent the input from being sent in the output?
Also, how can I test this with Postman?
I tried several URLs in my Postman request, but the inputs are not being received.

get : http://127.0.0.1:8080/api/Calculator.Add/?Data={N1:1,N2:2}
post : http://127.0.0.1:8080/api/Calculator.Add
body-raw : {Data={"N1":1,"N2":2}}

#50 Re: mORMot 2 » Where do I start? » 2024-06-29 13:03:52

Based on what I have learned, I wanted to create an interface-based server.
I do not want to use ORM on my server. That's why I did not create a class for orm and data.
The program stops with an error and I don't understand why.

---I have removed the code to comply with the rules.

Board footer

Powered by FluxBB