#1 2020-04-25 08:45:22

oerjann
Member
From: Norway
Registered: 2016-01-22
Posts: 7
Website

Authenticate to API using mORMot

Hello.
Could someone familiar with mORMot please have a look at the code in the link below, and tell me if the same thing can be accomplished using Delphi and mORMot? If so, any tips on where to start would be highly appreciated. Thanks!

https://developer.unieconomy.no/wiki/in … pplication

Offline

#2 2020-04-25 08:52:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Authenticate to API using mORMot

You have the HTTP/HTTPS client in SynCrtSock and some easy JSON process via TDocVariant in SynCommons.

Offline

#3 2020-04-25 11:33:35

oerjann
Member
From: Norway
Registered: 2016-01-22
Posts: 7
Website

Re: Authenticate to API using mORMot

What about the x509 certificate and the JWT security token needed to authenticate?

Offline

#4 2020-04-25 13:36:33

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Authenticate to API using mORMot

Ah: I didn't see it.

There is EVP_sha256_sign() in SynOpenSSL.pas which could be used for the signature.
But a new JWT class for RS256 algorithm is needed.

Offline

#5 2020-04-25 13:49:30

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Authenticate to API using mORMot

As a work around Step1 can be done in external .NET executable or DLL. The result of step1 is a <local generated jwt-token> string what can be used as a client_assertion header value for HTTP/HTTPS client from SynCrtSock

Last edited by mpv (2020-04-25 13:50:53)

Offline

#6 2020-04-25 15:31:27

oerjann
Member
From: Norway
Registered: 2016-01-22
Posts: 7
Website

Re: Authenticate to API using mORMot

So, if I understand it correctly, mORMot have everything needed to achieve the same as the code in the link, except for a JWT class for RS256 algorithm? Can I get my hopes up for such a class being made in the mORMot framework, or should I go for the workaround suggested by mpv? Off course doing all in Delphi code is preferred.

Offline

#7 2020-04-25 16:53:25

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Authenticate to API using mORMot

Currently we do not have a X509 parser. Either we should use a OpenSSL (preferred way as for me) or wrote/adopt some ASN parser (huge work). The simplest way to solve your task right now is to use small external program.

Offline

#8 2020-04-25 17:52:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Authenticate to API using mORMot

Try to make your own TJWTRS256 class, following for instance how it is implemented in SynEcc.pas.

Offline

Board footer

Powered by FluxBB