question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document/Example using JWT Header

See original GitHub issue

Here is a sample of what we have to do to wire up a JWT auth scheme to call our client services. Simply by defining this bean in the admin service project, all outbound calls have the token applied and should pass the remote services JWT auth requirement.

It might be prudent to add this to the security section or examples on how to do this in addition to the basic auth example already provided.

package com.foo.bar;

import de.codecentric.boot.admin.model.Application;
import de.codecentric.boot.admin.web.client.HttpHeadersProvider;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;

@Component
public class JwtHeaderProvider implements HttpHeadersProvider {

    @Override
    public HttpHeaders getHeaders(Application application) {
        HttpHeaders headers = new HttpHeaders();
        headers.add("X-Authn-JWT", "[MY TOKEN PROBABLY GENERATED WITH KEY]");
        return headers;
    }
}

This above works because of the @ConditionalOnMissingBean in your AdminServerCoreConfiguration class.

@Bean
@ConditionalOnMissingBean
public HttpHeadersProvider httpHeadersProvider() {
    return new BasicAuthHttpHeaderProvider();
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

6reactions
indraneelb1903commented, Jul 16, 2018

Although I think it is trivial too , but for people who are new to Spring Boot and Auto Configuration magic , this could be a useful addition.

2reactions
joshistecommented, Apr 27, 2017

Yeah that’s exactly what’s intended. Do you really think it should be in the docs - I don’t. Isn’t this trivial?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Web Token Introduction - jwt.io
Header. The header typically consists of two parts: the type of the token, which is JWT, and the signing algorithm being used, such...
Read more >
JSON Web Token Tutorial using AngularJS & Laravel - Toptal
This JWT example header declares that the encoded object is a JSON Web Token, and that it is signed using the HMAC SHA-256...
Read more >
Basic Usage — flask-jwt-extended 4.4.4 documentation
You use create_access_token() to make JSON Web Tokens, jwt_required() to protect ... By default, this is done with an authorization header that looks...
Read more >
Postman JWT Token Example: How to authenticate requests
In this tutorial, you'll see a Postman JWT Token Example and how to authenticate requests. Download a free Postman Keyboard Shortcuts Cheat ...
Read more >
JSON Web Token - Paw Cloud
It represents a JSON object that is signed using JSON Web Signature.JWT consists of three parts: Header, Payload (often called JWT Claims) and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found