Skip to content

Move key-token to header instead of body #663

Closed

Description

@vlidholt

Is your feature request related to a problem? Please describe.
As discussed here #657 it may be better to pass the key token for signed in users in the header instead of a URL query parameter.

Additional context
This is not a large security risk as the URL isn't typically visible or stored in history or cache. It's possible both a query parameter and header can be used simultaneously, making this change backwards compatible.

Activity

  1. damienissa commented on Feb 17, 2023

    @damienissa
    Contributor

    @vlidholt Hi. Can I commit to it?

  2. vlidholt commented on Feb 18, 2023

    @vlidholt
    CollaboratorAuthor

    @damienissa Yes, as long as it is backwards compatible, this would be a great addition! :)

  3. wstrange commented on Mar 9, 2023

    @wstrange
    Contributor

    Proxies and/or load balancers might log the URL. This isn't hair on fire, but it probably should be addressed in the next release.

  4. vlidholt commented on Mar 14, 2023

    @vlidholt
    CollaboratorAuthor

    Good point @wstrange

  5. added
    enhancement
    on Mar 14, 2023
  6. yahu1031 commented on Apr 8, 2023

    @yahu1031
    Contributor

    @davideroffo Currently, I'm able to pass the token in headers. When you consume in the server part, we need to use the session.

    sample code

    Future<CustomUserObject> getUserInfo(Session session, String id) async {
      if (session is MethodCallSession) {
        if(session.httpRequest.headers.value('Authorization') == null) {
          throw UserException(
            message: UserExceptionCode.unauthorized.message,
            code: UserExceptionCode.unauthorized.code,
          );
        }
      }
      // ... YOUR CODE ... //
    }

    Correct me if I'm doing something wrong/ not exactly correct.

    CC: @vlidholt

  7. perumalrollfi commented on May 22, 2023

    @perumalrollfi

    How do we add the header parameter in serverpod flutter app while calling the endpoint? We would like to add JWT token received while login for signed in users in header to authenticate on server side similar what is mentioned above.

  8. fstof commented on Aug 16, 2023

    @fstof

    I would also like to know what the client (flutter) side code looks like to send the header. I'm not finding anything related in the docs.

    For me this is a deal breaker as our infrastructure has all apis behind an api gateway / reverse proxy that requires a bearer token in the headers.
    Without this I cannot make any calls from my ui to backend as the proxy will reject the call

  9. vlidholt commented on Aug 21, 2023

    @vlidholt
    CollaboratorAuthor

    @fstof, adding custom headers would be a nice feature.

  10. fstof commented on Aug 21, 2023

    @fstof

    @fstof, adding custom headers would be a nice feature.

    @vlidholt I have a PR I'm just cleaning up if you don't mind...

    I'm thinking similar to AuthenticationKeyManager we can add a "headerManager" that can be passed in on client creation

    Client(
      'http://localhost:8080/',
      headerManager: CustomHeaderManager(),
    )

    ... and the abstract class...

    abstract class HeaderManager {
      Future<Map<String, String>?> get();
    }
  11. fstof commented on Sep 12, 2023

    @fstof

    So any takers on #1298 @vlidholt , @Isakdl ?

    Not exactly sure what the issue is on the web implementation of my PR
    Would really appreciate some input here

  12. vlidholt commented on Sep 13, 2023

    @vlidholt
    CollaboratorAuthor

    Sorry for the delay here. Will take a look shortly!

  13. lukehutch commented on Jan 31, 2024

    @lukehutch
    Contributor

    Related to JWT support requests: #1698, #1720.

  14. fstof commented on Jan 31, 2024

    @fstof

    Related to JWT support requests: #1698, #1720.

    Not exactly... those refer to the format of the auth key. Here the issue is the location of the token. IE Header vs Body
    using "Authorization" header is standard practice and would be ideal

  15. lukehutch commented on Feb 1, 2024

    @lukehutch
    Contributor

    @fstof Right, but what I'm saying is that the token itself should be a JWT. Yes, it should be stored in a header.

  16. moved this to Version 2.0 - Nice to have 🥳 in Serverpod Frameworkson Feb 5, 2024
  17. changed the title [-]Move key-token to header instead of URL[/-] [+]Move key-token to header instead of body[/+] on Aug 19, 2024
  18. moved this from Now 🔥 to Done 🚀 in Serverpod Frameworkson Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions