You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by GitBox <gi...@apache.org> on 2021/04/07 13:00:53 UTC

[GitHub] [knox] smolnar82 opened a new pull request #430: KNOX-2571 - Introducing Knox Home page profiles

smolnar82 opened a new pull request #430:
URL: https://github.com/apache/knox/pull/430


   ## What changes were proposed in this pull request?
   
   Added the ability to declare an arbitrary number of homepage profiles in `gateway-site.xml`. The relevant configuration prefix is `knox.homepage.profile.` which should be finished with the profile name (e.g. `knox.homepage.profile.smolnar` declares the profile called `smolnar`).
   The purpose of these profiles is to
   - control what's going to be displayed in General Proxy Information
   - optionally, filter topologies too
   
   The following language elements should be used when declaring a profile in `gateway-site.xml`
   - gpi_version - allows `Knox Version`
   - gpi_cert - allows `TLS Public Certificate`
   - gpi_admin_ui - allows `Admin UI URL`
   - gpi_admin_api - allows `Admin API Details`
   - gpi_md_api - allows `Metadata API`
   - gpi_tokens - allows `Integration Tokens`
   - top_$TOPOLOGY_LIST - allows to define a comma-separated list of topology names that should be included in the `Topologies` section
   
   Let's see a sample:
   ```
       <property>
           <name>knox.homepage.profile.smolnar</name>
           <value>gpi_version,gpi_tokens,top_other</value>
       </property>
   ```
   The `smolnar` profile will allow displaying the `Knox Version` and `Integration Tokens` elements in `General Proxy Information` and will filter topologies such as only the topology called `other` will be displayed in `Topologies`.
   
   Other than adding homepage profile support I also moved the session information block (username and optional logout button) into the top-left corner.
   
   ## How was this patch tested?
   
   Manually tested (I used the above described `smolnar` profile during my tests):
   <img width="1668" alt="Screen Shot 2021-04-07 at 2 41 43 PM" src="https://user-images.githubusercontent.com/34065904/113870239-ead89480-97b1-11eb-95f3-e0f3037a63c4.png">
   <img width="1673" alt="Screen Shot 2021-04-07 at 2 41 57 PM" src="https://user-images.githubusercontent.com/34065904/113870253-edd38500-97b1-11eb-8ed2-451c36ad2791.png">
   <img width="1668" alt="Screen Shot 2021-04-07 at 2 42 12 PM" src="https://user-images.githubusercontent.com/34065904/113870257-ee6c1b80-97b1-11eb-9c49-ec3106648aa4.png">
   <img width="1668" alt="Screen Shot 2021-04-07 at 2 42 35 PM" src="https://user-images.githubusercontent.com/34065904/113870260-ef04b200-97b1-11eb-8302-6c1faac091e4.png">
   <img width="1672" alt="Screen Shot 2021-04-07 at 2 43 23 PM" src="https://user-images.githubusercontent.com/34065904/113870262-ef9d4880-97b1-11eb-97dd-77d0a5fc7b08.png">
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 merged pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 merged pull request #430:
URL: https://github.com/apache/knox/pull/430


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] pzampino commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
pzampino commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r608927174



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Why not reference the constants in the Profile class?
   
   I might go so far as to define the arrays as constants too.
   
   ```
   static final String[] PROFILE_FULL = {PROFILE_GPI_VERSION, PROFILE_GPI_CERT, PROFILE_GPI_ADMIN_UI, PROFILE_GPI_ADMIN_API, PROFILE_GPI_META_API, PROFILE_GPI_TOKENS};
   
   static final String[] PROFILE_THIN = {PROFILE_GPI_VERSION, PROFILE_GPI_CERT};
   
   static final String[] PROFILE_TOKEN = {PROFILE_GPI_VERSION, PROFILE_GPI_TOKENS};
   ```

##########
File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
##########
@@ -250,4 +253,18 @@ private ServiceModel getServiceModel(HttpServletRequest request, String gatewayP
     return serviceModel;
   }
 
+  @GET
+  @Produces({ APPLICATION_JSON })
+  @Path("profiles/{profile}")
+  public String getProfile(@PathParam("profile") String profileName) {
+    final GatewayConfig config = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+    final Map<String, Collection<String>> configuredProfiles = config.getHomePageProfiles();
+    if (configuredProfiles.containsKey(profileName)) {

Review comment:
       Are profile names case-sensitive?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609065048



##########
File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
##########
@@ -250,4 +253,18 @@ private ServiceModel getServiceModel(HttpServletRequest request, String gatewayP
     return serviceModel;
   }
 
+  @GET
+  @Produces({ APPLICATION_JSON })
+  @Path("profiles/{profile}")
+  public String getProfile(@PathParam("profile") String profileName) {
+    final GatewayConfig config = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+    final Map<String, Collection<String>> configuredProfiles = config.getHomePageProfiles();
+    if (configuredProfiles.containsKey(profileName)) {

Review comment:
       Fixed.

##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609059742



##########
File path: gateway-service-metadata/src/main/java/org/apache/knox/gateway/service/metadata/KnoxMetadataResource.java
##########
@@ -250,4 +253,18 @@ private ServiceModel getServiceModel(HttpServletRequest request, String gatewayP
     return serviceModel;
   }
 
+  @GET
+  @Produces({ APPLICATION_JSON })
+  @Path("profiles/{profile}")
+  public String getProfile(@PathParam("profile") String profileName) {
+    final GatewayConfig config = (GatewayConfig) request.getServletContext().getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE);
+    final Map<String, Collection<String>> configuredProfiles = config.getHomePageProfiles();
+    if (configuredProfiles.containsKey(profileName)) {

Review comment:
       I'm going to make it case-insensitive.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] pzampino commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
pzampino commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r608927174



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Why not reference the constants in the Profile class?
   
   I might go so far as to define the arrays as constants too.
   
   ```
   static final String[] PROFILE_FULL = {Profile.GPI_VERSION, Profile.GPI_CERT, Profile.GPI_ADMIN_UI, Profile.GPI_ADMIN_API, Profile.GPI_METADATA_API, Profile.GPI_TOKENS};
   
   static final String[] PROFILE_THIN = {Profile.GPI_VERSION, Profile.GPI_CERT};
   
   static final String[] PROFILE_TOKEN = {Profile.GPI_VERSION, Profile.GPI_TOKENS};
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609044290



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Yepp; I'm going to figure out how to get rid of circular dependency and submit a new patch.

##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Yepp; I'm going to figure out how to get rid of circular dependency and submit a new patch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] moresandeep commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
moresandeep commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609000893



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {

Review comment:
       i don't follow what `this` object is here

##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Why not define these as static constants? added and reduced when needed (by cloning)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609064939



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {
+      if (config.getKey().startsWith(KNOX_HOMEPAGE_PROFILE_PREFIX)) {
+        profiles.put(config.getKey().substring(KNOX_HOMEPAGE_PROFILE_PREFIX.length()), getTrimmedStringCollection(config.getKey()));
+      }
+    });
+    return profiles;
+  }
+
+  private Map<String, Collection<String>> getPreConfiguredProfiles() {
+    final Map<String, Collection<String>> profiles = new HashMap<>();
+    profiles.put("full", Arrays.asList("gpi_version", "gpi_cert", "gpi_admin_ui", "gpi_admin_api", "gpi_md_api", "gpi_tokens"));

Review comment:
       Fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [knox] smolnar82 commented on a change in pull request #430: KNOX-2571 - Introducing Knox Home page profiles

Posted by GitBox <gi...@apache.org>.
smolnar82 commented on a change in pull request #430:
URL: https://github.com/apache/knox/pull/430#discussion_r609043733



##########
File path: gateway-server/src/main/java/org/apache/knox/gateway/config/impl/GatewayConfigImpl.java
##########
@@ -1209,4 +1211,23 @@ public long getKeystoreCacheEntryTimeToLiveInMinutes() {
   public boolean isGatewayServerIncomingXForwardedSupportEnabled() {
     return getBoolean(KNOX_INCOMING_XFORWARDED_ENABLED, true);
   }
+
+  @Override
+  public Map<String, Collection<String>> getHomePageProfiles() {
+    final Map<String, Collection<String>> profiles = getPreConfiguredProfiles(); // pre-configured profiles might be overwritten
+    this.forEach(config -> {

Review comment:
       This class implements `Iterable`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org