Uploaded image for project: 'WildFly Elytron'
  1. WildFly Elytron
  2. ELY-2900

Cookie fallback in BearerTokenAuthenticationMechanism

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Optional Optional
    • None
    • None
    • HTTP
    • None

      Currently org.wildfly.security.http.bearer.BearerTokenAuthenticationMechanism does not support reading the jwt token from cookies. Is it possible to add (maybe as a fallback?) in case there doesn't exist an authorization header?

       
      @Override
      public void evaluateRequest(HttpServerRequest request) throws HttpAuthenticationException {
          // Read token from authorization header
          List<String> authorizationValues = request.getRequestHeaderValues(HttpConstants.AUTHORIZATION);
          // Fallback: read token from cookies, if no authorization-header present
          if (authorizationValues == null || authorizationValues.isEmpty()) {
              List<HttpServerCookie> cookies = request.getCookies(); // Cookie handling
              if (cookies != null) {
                  for (HttpServerCookie cookie : cookies) {
                      if (HttpConstants.AUTHORIZATION.equals(cookie.getName())) {
                          authorizationValues = Collections.singletonList("Bearer " + cookie.getValue());
                          break;
                      }
                  }
              }
          }
      

      Thanks.

              darran.lofthouse@redhat.com Darran Lofthouse
              murphy99_jira Robert Palm
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: