This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch 5.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/5.0.x by this push:
     new 8f2ad92  traffic router re-authentication on unauthorized (#5177) 
(#5223)
8f2ad92 is described below

commit 8f2ad923ec586c35d2b34f31a2292f0d71717075
Author: ocket8888 <[email protected]>
AuthorDate: Thu Oct 29 13:27:40 2020 -0600

    traffic router re-authentication on unauthorized (#5177) (#5223)
    
    * traffic router re-authentication on unauthorized
    
    * Add Changelog entry
    
    Co-authored-by: nir-sopher <[email protected]>
    Co-authored-by: Steve Malenfant <[email protected]>
    (cherry picked from commit 542730b7352adc6a15ee9534eee69c372c48936b)
    
    Co-authored-by: Steve Malenfant <[email protected]>
---
 CHANGELOG.md                                                     | 1 +
 .../traffic_router/core/util/ProtectedFetcher.java               | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index af6cc90..e0911c0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -114,6 +114,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - Fixed #5180 - Global Max Mbps and Tps is not send to TM
 - Fixed #3528 - Fix Traffic Ops monitoring.json missing DeliveryServices
 - Fixed an issue where the jobs and servers table in Traffic Portal would not 
clear a column's filter when it's hidden
+- Fixed an issue with Traffic Router failing to authenticate if secrets are 
changed
 
 ### Changed
 - Changed some Traffic Ops Go Client methods to use `DeliveryServiceNullable` 
inputs and outputs.
diff --git 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/ProtectedFetcher.java
 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/ProtectedFetcher.java
index b389a2c..65e34cc 100644
--- 
a/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/ProtectedFetcher.java
+++ 
b/traffic_router/core/src/main/java/com/comcast/cdn/traffic_control/traffic_router/core/util/ProtectedFetcher.java
@@ -32,10 +32,15 @@ public class ProtectedFetcher extends Fetcher {
 
        @Override
        protected HttpURLConnection getConnection(final String url, final 
String data, final String method, final long lastFetchedTime) throws 
IOException {
-               if (!isCookieValid()) {
-                       
extractCookie(super.getConnection(getAuthorizationEndpoint(), getData(), 
POST_STR, 0L, CONTENT_TYPE_JSON));
+
+               if (isCookieValid()) {
+                       final HttpURLConnection connection = 
extractCookie(super.getConnection(url, data, method, lastFetchedTime));
+                       if (connection.getResponseCode() != 
HttpURLConnection.HTTP_UNAUTHORIZED) {
+                               return connection;
+                       }
                }
 
+               extractCookie(super.getConnection(getAuthorizationEndpoint(), 
getData(), POST_STR, 0L));
                return extractCookie(super.getConnection(url, data, method, 
lastFetchedTime));
        }
 

Reply via email to