Repository: jhipster/jhipster-registry
Issue: Registry docker image requires JWT base64-secret in oauth2 profile

<!--
- Please follow the issue template below for bug reports and feature requests.
- If you have a support request rather than a bug, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/jhipster) with the JHipster tag.
- For bug reports it is mandatory to run the command `jhipster info` in your project's root folder, and paste the result here.
- Tickets opened without any of these pieces of information will be **closed** without any explanation.
-->

##### **Overview of the issue**
JWT base64-secret should not be mandatory in oauth2 profile
<!-- Explain the bug or feature request, if an error is being thrown a stack trace helps -->

##### **Motivation for or Use Case**

<!-- Explain why this is a bug or a new feature for you -->

##### **Reproduce the error**
- Generate the JHipster application with OIDC authentication and select integration with JHipster Registry
- Start the Keycloak container
- Start `jhipster-registry` container -- `docker-compose -f src/main/docker/jhipster-registry up`
- You shall see startup errors due to the null `base64-secret` configuration required by TokenProvider. 
- Specify some dummy long base64-secret under `src/main/docker/central-server-config/localhost-config/application.yml` and start JHipster Registry again. This time you should see the registry starts up correctly.

<!-- For bug reports, an unambiguous set of steps to reproduce the error -->

##### **Related issues**

<!-- Has a similar issue been reported before? Please search both closed & open issues -->

##### **Suggest a Fix**

<!-- For bug reports, if you can't fix the bug yourself, perhaps you can point to what might be
  causing the problem (line of code or commit) -->

##### **JHipster Registry Version(s)**

<!--
Which version of JHipster Registry are you using, is it a regression?
-->

##### **Browsers and Operating System**

<!-- What OS are you on? is this a problem with all browsers or only IE8? -->

- [ ] Checking this box is mandatory (this is just to show you read everything)


Changed files:
src/main/java/tech/jhipster/registry/security/jwt/TokenProvider.java
src/main/java/tech/jhipster/registry/web/rest/UserJWTController.java
src/main/java/tech/jhipster/registry/security/oauth2/JwtGrantedAuthorityConverter.java

diff --git a/src/main/java/tech/jhipster/registry/security/jwt/TokenProvider.java b/src/main/java/tech/jhipster/registry/security/jwt/TokenProvider.java
index e8a382c..059d642 100644
--- a/src/main/java/tech/jhipster/registry/security/jwt/TokenProvider.java
+++ b/src/main/java/tech/jhipster/registry/security/jwt/TokenProvider.java
@@ -20,7 +20,6 @@ import org.springframework.util.ObjectUtils;
 import tech.jhipster.config.JHipsterProperties;
 import tech.jhipster.registry.management.SecurityMetersService;
 
-@Component
 public class TokenProvider {
 
     private final Logger log = LoggerFactory.getLogger(TokenProvider.class);
diff --git a/src/main/java/tech/jhipster/registry/security/oauth2/JwtGrantedAuthorityConverter.java b/src/main/java/tech/jhipster/registry/security/oauth2/JwtGrantedAuthorityConverter.java
index 08a91ac..9ae9db6 100644
--- a/src/main/java/tech/jhipster/registry/security/oauth2/JwtGrantedAuthorityConverter.java
+++ b/src/main/java/tech/jhipster/registry/security/oauth2/JwtGrantedAuthorityConverter.java
@@ -7,7 +7,6 @@ import org.springframework.security.oauth2.jwt.Jwt;
 import org.springframework.stereotype.Component;
 import tech.jhipster.registry.security.SecurityUtils;
 
-@Component
 public class JwtGrantedAuthorityConverter implements Converter<Jwt, Collection<GrantedAuthority>> {
 
     public JwtGrantedAuthorityConverter() {
diff --git a/src/main/java/tech/jhipster/registry/web/rest/UserJWTController.java b/src/main/java/tech/jhipster/registry/web/rest/UserJWTController.java
index 39f414a..5506b9c 100644
--- a/src/main/java/tech/jhipster/registry/web/rest/UserJWTController.java
+++ b/src/main/java/tech/jhipster/registry/web/rest/UserJWTController.java
@@ -2,6 +2,7 @@ package tech.jhipster.registry.web.rest;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
 import javax.validation.Valid;
+import org.springframework.context.annotation.Profile;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -10,6 +11,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
+import tech.jhipster.registry.config.Constants;
 import tech.jhipster.registry.security.jwt.JWTFilter;
 import tech.jhipster.registry.security.jwt.TokenProvider;
 import tech.jhipster.registry.web.rest.vm.LoginVM;
@@ -19,6 +21,7 @@ import tech.jhipster.registry.web.rest.vm.LoginVM;
  */
 @RestController
 @RequestMapping("/api")
+@Profile("!" + Constants.PROFILE_OAUTH2)
 public class UserJWTController {
 
     private final TokenProvider tokenProvider;