Validating tokens

The Waher.Security.JWT.UWP library also contains the JwtAuthentication class that authenticates web requests based on JWT tokens. We first need to define a variable for it:

private JwtAuthentication tokenAuthentication; 

When we've established the device identity, which we will use as a realm, we create an instance of this authenticator (the realm allows browsers to isolate credentials between sites):

this.tokenAuthentication = new JwtAuthentication(this.deviceId, 
   this.users, this.tokenFactory); 

The authenticator references our users database to check that subjects match users in the database. It also references the token factory to validate that tokens are correctly signed. We then simply add the reference to the authenticator as the last parameter to all the web service resource registrations that we want to protect.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.121.160