moresandeep commented on code in PR #1082:
URL: https://github.com/apache/knox/pull/1082#discussion_r2333477389


##########
knox-token-generation-ui/token-generation/app/token-generation.service.ts:
##########
@@ -73,14 +75,31 @@ export class TokenGenService {
         });
     }
 
+    isTokenHashKeyPresent(): Promise<boolean> {
+        let headers = new HttpHeaders();
+        headers = this.addHeaders(headers);
+        return this.http.get(this.metadataInfoUrl, { headers: headers})
+            .toPromise()
+            .then(response => {
+                return response['generalProxyInfo']?.['enableTokenManagement'] 
=== 'true';
+            })
+            .catch((err: HttpErrorResponse) => {
+                console.debug('TokenGenService --> isTokenHashKeyPresent() --> 
' + this.metadataInfoUrl + '\n  error: ' + err.message);

Review Comment:
   Might want to remove the debug message.



##########
knox-token-management-ui/token-management/app/token.management.service.ts:
##########
@@ -129,6 +130,25 @@ export class TokenManagementService {
             });
     }
 
+    isTokenHashKeyPresent(): Promise<boolean> {
+        let headers = new HttpHeaders();
+        headers = this.addJsonHeaders(headers);
+        return this.http.get(this.metadataInfoUrl, { headers: headers})
+            .toPromise()
+            .then(response => {
+                return response['generalProxyInfo']?.['enableTokenManagement'] 
=== 'true';
+            })
+            .catch((err: HttpErrorResponse) => {
+                console.debug('TokenManagementService --> 
isTokenHashKeyPresent() --> '

Review Comment:
   Debug



##########
knox-token-management-ui/token-management/app/token.management.component.ts:
##########
@@ -121,8 +136,12 @@ export class TokenManagementComponent implements OnInit {
     }
 
     fetchKnoxTokens(): void {
-        this.tokenManagementService.getKnoxTokens(this.userName, 
this.canSeeAllTokens)
-            .then(tokens => this.updateTokens(tokens));
+        if (this.tokenHashKeyPresent) {
+            this.tokenManagementService.getKnoxTokens(this.userName, 
this.canSeeAllTokens)
+                .then(tokens => this.updateTokens(tokens));
+        } else {
+            console.debug('knox.token.hash.key is missing, skipping Knox token 
fetch...');

Review Comment:
   Debug :) 



##########
knox-token-generation-ui/token-generation/app/token-generation.service.ts:
##########
@@ -73,14 +75,31 @@ export class TokenGenService {
         });
     }
 
+    isTokenHashKeyPresent(): Promise<boolean> {
+        let headers = new HttpHeaders();
+        headers = this.addHeaders(headers);
+        return this.http.get(this.metadataInfoUrl, { headers: headers})
+            .toPromise()
+            .then(response => {
+                return response['generalProxyInfo']?.['enableTokenManagement'] 
=== 'true';
+            })
+            .catch((err: HttpErrorResponse) => {
+                console.debug('TokenGenService --> isTokenHashKeyPresent() --> 
' + this.metadataInfoUrl + '\n  error: ' + err.message);
+                if (err.status === 401) {
+                    window.location.assign(document.location.pathname);
+                } else {
+                    return this.handleError(err);
+                }
+            });
+    }
     getSessionInformation(): Promise<SessionInformation> {
         let headers = new HttpHeaders();
         headers = this.addHeaders(headers);
         return this.http.get(this.sessionUrl, { headers: headers})
             .toPromise()
             .then(response => response['sessioninfo'] as SessionInformation)
             .catch((err: HttpErrorResponse) => {
-                console.debug('TokenManagementService --> 
getSessionInformation() --> ' + this.sessionUrl + '\n  error: ' + err.message);
+                console.debug('TokenGenService --> getSessionInformation() --> 
' + this.sessionUrl + '\n  error: ' + err.message);

Review Comment:
   Same thing, do we need to display error messages to users on console? There 
could be a case made where it might help troubleshoot issues faster but 
displaying messages on console is not my favorite way to display errors :) 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to