#1 2017-12-05 13:17:05

MCvanderKooij
Member
From: Netherlands, Stadskanaal
Registered: 2017-12-01
Posts: 4
Website

JWT with RS256, RS384 and RS512

Hi,

I have created this support for RS256, RS384 and RS512 in JWT using openssl.

Files are included in this zip:
https://www.dropbox.com/s/hnuf3qsgx3o52 … S.zip?dl=0

It needs a few additions to openssl.pas which is also included.

Both signing and verifying works. Feel free to use in mORMot (even better, because you will probably optimize it further :-) )

Kind regards,
Martijn

Offline

#2 2017-12-05 13:53:57

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

Re: JWT with RS256, RS384 and RS512

I've integrated the SynOpenSSL.pas  small additions, but the rest needs more review.
See https://synopse.info/fossil/info/41a009ce3c

Thanks for sharing!

Offline

#3 2017-12-05 15:19:00

MCvanderKooij
Member
From: Netherlands, Stadskanaal
Registered: 2017-12-01
Posts: 4
Website

Re: JWT with RS256, RS384 and RS512

ab wrote:

I've integrated the SynOpenSSL.pas  small additions, but the rest needs more review.
See https://synopse.info/fossil/info/41a009ce3c

Thanks for sharing!


Great, that makes maintaince easier...

And a small fix in TJWTAsymetric.SetPublicKey:

The "FPublicKey := Value;" needs to be after the "if FPublicKey <> Value then"...

(Always nice those last moment changes...)

Offline

#4 2018-04-23 10:49:25

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

Re: JWT with RS256, RS384 and RS512

@ab - do you have any plans to add @MCvanderKooij TJWTAsymetric to the main mORMot trunk? We need it for integration with 3-d party services (payments). If not - it's not a problem...

Online

#5 2020-12-28 10:10:45

squirrel
Member
Registered: 2015-08-13
Posts: 155

Re: JWT with RS256, RS384 and RS512

Is it possible to create RS256 JWT assertions using mormot? 
I need to integrate with 3rd party systems that requires it, and looking for a pain-free way to generate the jwt assertions.  Unfortunately rs256 is a requirement from them.

Offline

#6 2020-12-28 10:33:50

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

Re: JWT with RS256, RS384 and RS512

Eventually in mORMot2, using OpenSSL.

Current SynOpenSSL has already support for raw RS* algorithms, you need to create a TJWTAbstract sub-class to call the corresponding OpenSSL functions.

Offline

#7 2020-12-28 11:40:12

squirrel
Member
Registered: 2015-08-13
Posts: 155

Re: JWT with RS256, RS384 and RS512

Thanks ab

It looks like the code provided by @MCvanderKooij works very well as-is, I just had to add SynTable to the uses clause of uJWTRSA.

Offline

#8 2020-12-28 22:11:49

Vitaly
Member
From: UAE
Registered: 2017-01-31
Posts: 168
Website

Re: JWT with RS256, RS384 and RS512

JOSE JWT lib can be also used with TJWTAbstract subclass as an alternative: https://github.com/paolo-rossi/delphi-jose-jwt

Offline

Board footer

Powered by FluxBB