Jump to content

Stuart Clennett

  • Content Count

  • Joined

  • Last visited

  • Days Won


Stuart Clennett last won the day on December 13 2018

Stuart Clennett had the most liked content!

Community Reputation

7 Neutral

Technical Information

  • Delphi-Version
    Delphi 10.1 Berlin

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Stuart Clennett

    MarsToken.SaveToFile / LoadFromFile

    Thanks Andrea. Good luck with that 😉
  2. Stuart Clennett

    MarsToken.SaveToFile / LoadFromFile

    HI Andrea, Yes, that was it, I had AuthEndorsement set to cookie. So sorry, I thought I had checked that but clearly not. Kind regards
  3. Hi, I'm trying to save a JWT token to a file between program runs. I have a console app that runs on a short schedule and I want to prevent having to authenticate each time. I am using MarsClientToken SaveToStream / LoadFromStream to get the json token data into and out of a temp file. The contents of the temp file look fine & contain the json I would expect, i.e. the "Token" and each token property (the expired date is always +24hrs ) When the token data is loaded from the file, IsVerified = True, isExpired = false, and Authenticated = True, but I am getting 403 forbidden when I make my api calls. Logging in with username/password works fine of course. Is there something I am missing ? Thanks
  4. Stuart Clennett

    Adding a second app to a MARS Engine

    Thanks Andrea -- adding the server2.resources unit to the server.ignition.pas uses clause worked. Kind regards
  5. Hi, I've tried adding a second app to my MARS rest engine (in order to support my api's version 2) as follows: class constructor TServerEngine.CreateEngine; var MyApp, MyApp2 : TMARSApplication; begin FEngine := TMARSEngine.Create; try // Engine configuration FEngine.Parameters.LoadFromIniFile; // Application configuration MyApp := FEngine.AddApplication('IBCSApp', '/ibcs', [ 'Server.Resources.*']); // Second Application (version 2 of the API) MyApp2 := FEngine.AddApplication('IBCSApp2', '/ibcs2', [ 'server2.Resources.*']); // [....] End; And I've created a server2.Resources.pas file into which I've added a simple "/healthcheck" resource that returns the server time as a string. I've also added this line initialization TMARSResourceRegistry.Instance.RegisterResource<THealthCheck>; But when the server runs, IBCSApp2 is shown in the list of engines, but it does not contain the /healthcheck resource. I should mention that the original app (IBCSApp) also has the same resource name (/healthcheck) implemented by a different class. I guess I am missing something? Thanks Stuart
  6. That's excellent, thanks Andrea. Hope you're feeling better and had a nice christmas break. Regards Stuart
  7. Hi, Does anyone know the required steps to override the JWT params defaults for SECRET and ISSUER please? I can see they seem to need to be in the Activation.Parameters... but I'm not sure how to get them in there? Thanks in advance, Stuart
  8. Hi Andrea, Thanks for sorting this. I do have a github account (stuartclennett), but I'm not very familiar with git (aside from commit - push - checkout), so I wouldn't be very confident in dealing with pull-requests as yet. Thanks for mentioning me though. Should I add any bugs to the github issues directly rather than here in future? Thanks
  9. Hi, I use Charles proxy's black list function to test my apps response to a blocked connection. Charles can either return a 403 or just "drop the connection". When I set Charles to "drop the connection", the call to fHTTPClient.Post (in TMARSNetClient.Post) raises an exception and as a result fLastReponse remains nil. Therefore subsequent calls to TMARSNetClient.ResponseCode or TMARSNetClient.ResponseText raise an Access Violation. I have temporarily patched the code in MARS.Client.Client.Net.pas in the ResponseText & ResponseStatusCode functions by returning 0 (zero) for the response code & an empty string for the response text if the fLastResponse var is unassigned (code below). The exception raised is an ENetHTTPClientException with message "Error receiving data (12152). Server returned an invalid or unrecognized response". Kind regards, Stuart -- Delphi Berlin 10.1 Windows 10 function TMARSNetClient.ResponseStatusCode: Integer; begin if assigned(fLastResponse) then Result := FLastResponse.StatusCode else result := 0; end; function TMARSNetClient.ResponseText: string; begin if assigned(FLastResponse) then Result := FLastResponse.StatusText else result := ''; end;
  10. Stuart Clennett

    Error during Execute in MARSCmd

    HI Andrea, You're welcome - thanks for the great library 🙂 Yes, that makes sense, I will clean the MARSTemplate project. Kind regards Stuart
  11. Hi, I got FireDAC functionality working with the EMPLOYEE table. I wanted to load/save data using a json file for simple app config data, but as soon as I placed a TFDMemTable on the data module, I get an Access Violation when I request anything from that resource. (E.g. a GET on the original Employee table). The call stack says the a/v occurs in MARS.Data.FireDAC.TMARSFireDAC.InjectMacroValues(nil, True) which is in turn called from TMARSFDDataModuleResource.Retrieve. I have not changed any properties on the FDMemTable nor added any code. When I delete the component and recompile the server, the a/v goes away. This can be easily replicated using the FireDACBasic demo, by adding a TFDMemTable to the Server.MainData datamodule. Thanks for your help Stuart
  12. Stuart Clennett

    How to add FireDAC Datamodule as per the demo?

    Hi Bjørn, Yes, that was the missing piece of the jigsaw. I needed to add the server.fddata unit to the uses clause of server.ignite, and also the AddApplication filter was 'server.resources.*' which I have changed to 'server.*' My data resource appears in the list now. Many thanks
  13. Hi Andrea, I am trying to add a new datamodule to my MARS server that supports the FireDAC functions but the resource is not being included in the server app along with the others. I have inspected your "FireDAC Basic Demo" and I did the following: • Added MARS.Data.FireDAC.DataModule to my server project from the MARS\Source directory • Created a new DataModule by inheriting from that unit • Added the MARS units to the uses clause, as per your demo • Added the Path attribute • Added the Initialization section to add the datamodule to the MARSResourceRegistry.Instance However, on running the server I cannot see the resource listed in the treeview and it is not recognised when I try to access through the client. Is there something I have missed? Thanks The full datamodule source code is here: unit server.fddata; interface uses System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.IB, FireDAC.Phys.IBDef, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client , MARS.Data.FireDAC.DataModule , MARS.Core.Attributes , MARS.Core.URL , MARS.Core.Token ; type [Path('/data')] TFDData = class(TMARSFDDataModuleResource) EmployeeConnection: TFDConnection; EmployeeTable: TFDQuery; private public end; implementation {%CLASSGROUP 'Vcl.Controls.TControl'} uses MARS.Core.Registry; {$R *.dfm} Initialization TMARSResourceRegistry.Instance.RegisterResource<TFDData>; end.
  14. Stuart Clennett

    Token/Roles not working with TMARSNetClient

    Hi Andrea, I've asked another developer to run the tests. I only have 10,1 with no updates - I will try and install update 2 in the coming days to see if that makes any difference. Thanks Stuart
  15. Stuart Clennett

    Error during Execute in MARSCmd

    Hi Andrea, It appears the problem is in the TMARSCmd.ReplaceEverywhere method. Specifically the following line: if LNewFileName <> LFile then TFile.Move(LFile, LNewFileName); When the files are originally copied from the MARSTemplateClient\Bin folder the sub-folder name of "MARSTemplateClient" is not changed. So in the case of the target folder being %MARS%\Demos\OC2, the AndroidManifest.xml file is copied to %MARS%\Demos\OC2\bin\MARSTemplateClient\AndroidManifest,xml. When the ReplaceEverywhere routine runs the LNewFilename variable becomes %MARS%\Demos\OC2\bin\OC2\AndroidManifest,xml. This folder does not exist and so I'm encountering an error. I've patched it to get it working quickly by adding a ForceDirectories call before the TFile.Move - which works but leaves behind an empty folder structure OC2\bin\MARSTemplateClient . So I guess the original Execute procedure where it copies files maybe needs a little work ?? Regards Stuart (PS - I really like MARS - it's serving my first "proper" mobile app and it's acting as a microservice in a large enterprise desktop app too - thanks)