Document/Example using JWT Header
See original GitHub issueHere 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:
- Created 6 years ago
- Reactions:5
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Yeah that’s exactly what’s intended. Do you really think it should be in the docs - I don’t. Isn’t this trivial?