Four, JWT Comments (core version 2.2)






Address of mind mapping








Claim



Create a simple token

Declare an array of



debugging techniques

when the code changes, automatically exits monitoring file is modified, then start.

post test, token-generated


encryption algorithm does not

or suggest this is an invalid signature

, although generated token, but no digital signatures and encryption algorithms.

By looking at the source code to see there are five rewrite the method



so that our third, part of a digital signature is generated.



Why signature or not it?

Also you need to configure key.


Copy our keys over.

Key 123 is set to






parameter name, key size of

the key is at least 16-bit


string of copying only the second portion is placed inside the console to resolve chrpme



Get property values ​​in jwt


The first method requires its own generates a class to receive

a second user through the object is to acquire.

httpcontext context to get

our start just injected HttpContext. There is no other middleware.

Sending a request, values obtained are empty. Only the first one to get. 23 What are two ways to get to the null

Authentication



You must be registered in a holder in the service.





blogCore projects which are arranged in the configuration file

open middleware

if not open it?

It would not obtain the value of jwt


after opening

passed a token


role here is to transfer a string deserialized into an object jwt




must check


added Breakpoints

entered above ToList ()

released .net core of jwt map matching.

In this way we could get, to get to the email content

Api whether the test was protected

Add to authorize action.

Does not pass token access. 401 returned

to bring access token

How to use JWT

No state authority, directly [Autoirize] that you do not control what roles and policies.


For example, only the admin role before you can use


open authentication. The first step was to open certification AddAuthentication
The second step is a registered AddJwtBearer service,

the core is to verify the configuration parameters of

the last step, open middleware

Write your own middleware way to certification



The first is to open a custom middleware certification.





 

End

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/12593306.html