18887: Fix salted_secret check. Add test.
authorWard Vandewege <ward@curii.com>
Mon, 4 Apr 2022 19:01:18 +0000 (15:01 -0400)
committerWard Vandewege <ward@curii.com>
Mon, 4 Apr 2022 19:01:18 +0000 (15:01 -0400)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

lib/controller/integration_test.go
services/api/app/models/api_client_authorization.rb

index 442c9a6df350e2f347494a4f84d275d74c955032..b71c4afb55ba9a5ac9d3fb57efdb050d55c7a34b 100644 (file)
@@ -418,6 +418,15 @@ func (s *IntegrationSuite) TestForwardAnonymousTokenToLoginCluster(c *check.C) {
        )
        // The local z3333 anonymous token must be allowed to be forwarded to the login cluster
        c.Check(err, check.IsNil)
        )
        // The local z3333 anonymous token must be allowed to be forwarded to the login cluster
        c.Check(err, check.IsNil)
+
+       userac1.AuthToken = "v2/z1111-gj3su-asdfasdfasdfasd/this-token-does-not-validate-so-anonymous-token-will-be-used-instead"
+       err = userac1.RequestAndDecode(&userList, "GET", "/arvados/v1/users", nil,
+               map[string]interface{}{
+                       "reader_tokens": []string{anon3Auth.TokenV2()},
+                       "where":         where,
+               },
+       )
+       c.Check(err, check.IsNil)
 }
 
 // Get a token from the login cluster (z1111), use it to submit a
 }
 
 // Get a token from the login cluster (z1111), use it to submit a
index 726061a4ab41e00cf2e89475ca7190ffd3c14b89..52922d32b1868fdb53d8bcd3f1197d149a93bb63 100644 (file)
@@ -131,7 +131,7 @@ class ApiClientAuthorization < ArvadosModel
     end
 
     # Usually, the secret is salted
     end
 
     # Usually, the secret is salted
-    salted_secret = OpenSSL::HMAC.hexdigest('sha1', secret, remote)
+    salted_secret = OpenSSL::HMAC.hexdigest('sha1', Rails.configuration.Users.AnonymousUserToken, remote)
 
     # The anonymous token could be specified as a full v2 token in the config,
     # but the config loader strips it down to the secret part.
 
     # The anonymous token could be specified as a full v2 token in the config,
     # but the config loader strips it down to the secret part.