danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bearer authentication

viniciussanchez opened this issue · comments

Hi, I would like to know why to request a JWt token, do I have to use the POST method? And why did you create custom headers, being the default and using header authorization? If I make the settings to leave the API according to the Web standard, will you accept the pull request?

I have a server using DMVC, where it is responsible for receiving the user and password and generating the JWT token.
The DMVC is forcing me to use custom headers as long as header authorization already exists for this as a default. The DMVC is also forcing me to request my token through the POST method on how much it should be GET since I am not passing anything on the request body.

On the server that will be authenticated by JWT, it is also wrong. It forces me to pass the token on the Authenticate header as long as the default is the Authorization header. And the DMVC is still validating the header content as follows: "bearer dgasdkghdaskfghfasdf", while the default is "Bearer askfgsdkfghjkfalsdfglfkj"

I can adjust and perform the pull request if I can ...

You can define the name of your header when creating JWT middleware.

FEngine.AddMiddleware(TMVCJWTAuthenticationMiddleware.Create(
      TAuthenticationController.Create,
      LClaimsSetup,
      'MySecret', { Secret }
      '/api/login',
      [TJWTCheckableClaim.ExpirationTime, TJWTCheckableClaim.NotBefore, TJWTCheckableClaim.IssuedAt],
      300,
      'Authorization', { Header token }
      'username',      { Header UserName }
      'password'       { Header Password }
    ));

Yes I Can! But why define a name being that a pattern already exists?
And still, it still has several differences, as said the word Bearer locked with lowercase letter, the method forcing to be POST, I still have to set the user headers and password and there is already a default for this.

The Horse for example follows the correct pattern.

Thanl you for your notes @viniciussanchez .
Your PR will be appreciated.