Jump to content
Stuart Clennett

Overriding the JWT_SECRET_PARAM_DEFAULT & JWT_ISSUER_PARAM_DEFAULT

Recommended Posts

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

Share this post


Link to post

Hi @Stuart Clennett,

you can easily provide values for JWT configuration parameters through the server application configuration.

MARSTemplate based applications looks for an ini file (same name of the server application) structured this way:

[YourEngineName]
YourAppName.YourParam=YourValue

 

So, if you just cloned MARSTemplate with MARSCmd utility, you can change JWT secret and issuer this way:

 

[DefaultEngine]
DefaultApp.JWT.Secret=Andrea123
DefaultApp.JWT.Issuer=Andrea

 

Beware if you change the engine name (form DefaultEngine) or the application name (from DefaultApp) you'll need to correct your ini file.

Check you Server.Ignition.pas file and locate this line:     FEngine.Parameters.LoadFromIniFile;

This is where MARS tries to load configuration from the INI file.

If you want to hard-code (or read from different sources) parameters values you can either add this line, keeping in mind you are actually defining a value for a parameter named 'JWT.Issuer' of an application named 'DefaultApp' (and the application name has to match):

 

    FEngine.Parameters.LoadFromIniFile;
    FEngine.Parameters.Values['DefaultApp.JWT.Issuer'] := 'My Issuer';

Or directly define the 'JWT.Issuer' (or any other parameter) to the configuration of the specific application:

 

    // Application configuration
    LApp := FEngine.AddApplication('DefaultApp', '/default', [ 'Server.Resources.*']);
    LApp.Parameters.Values['JWT.Issuer'] := 'My Issuer';

 

There is no much difference between these two options, but the second one may be handy if the name of the application is not a constant.

A list of available JWT-related parameters (and their default values) is available here: https://github.com/andrea-magni/MARS/blob/master/Source/MARS.Utils.JWT.pas

 

Sorry for the late (holiday time plus I've been sick too). 

 

Sincerely,

Andrea

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×