16212: Populate all api_client_auth fields.
authorTom Clegg <tom@tomclegg.ca>
Tue, 7 Apr 2020 21:26:46 +0000 (17:26 -0400)
committerTom Clegg <tom@tomclegg.ca>
Tue, 7 Apr 2020 21:26:46 +0000 (17:26 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/controller/localdb/login_pam.go
lib/controller/localdb/login_pam_docker_test.sh
lib/controller/localdb/login_pam_test.go

index a9e60ccba1914f59994519351fcd47245f1d1047..01dfc1379d3064b06ad7a3e7760d60250cc00a52 100644 (file)
@@ -104,5 +104,6 @@ func (ctrl *pamLoginController) UserAuthenticate(ctx context.Context, opts arvad
        if err != nil {
                return arvados.APIClientAuthorization{}, err
        }
-       return arvados.APIClientAuthorization{APIToken: target.Query().Get("api_token")}, err
+       token := target.Query().Get("api_token")
+       return ctrl.RailsProxy.APIClientAuthorizationCurrent(auth.NewContext(ctx, auth.NewCredentials(token)), arvados.GetOptions{})
 }
index 3feba58ec3958cbf5d0a1985f7dbfc04f28f9b7b..b8f281bc2e69dfd80f3c3451b161330bbc0a2d47 100755 (executable)
@@ -186,6 +186,8 @@ check_contains "${resp}" '{"errors":["PAM: Authentication failure (with username
 echo >&2 "Testing authentication success"
 resp="$(curl -s --include -d username=foo -d password=secret "http://${ctrlhostport}/arvados/v1/users/authenticate" | tee $debug)"
 check_contains "${resp}" "HTTP/1.1 200"
-check_contains "${resp}" '{"api_token":"v2/zzzzz-gj3su-'
+check_contains "${resp}" '"api_token":"'
+check_contains "${resp}" '"scopes":["all"]'
+check_contains "${resp}" '"uuid":"zzzzz-gj3su-'
 
 cleanup
index d32aa1f24656977c5c094fa243429b5fa879b05b..5b0e4533e1844c543539ebab7567e8ca2973d82c 100644 (file)
@@ -74,7 +74,9 @@ func (s *PamSuite) TestLoginSuccess(c *check.C) {
                Password: p,
        })
        c.Check(err, check.IsNil)
-       c.Check(resp.APIToken, check.Matches, `v2/zzzzz-gj3su-.*/.*`)
+       c.Check(resp.APIToken, check.Not(check.Equals), "")
+       c.Check(resp.UUID, check.Matches, `zzzzz-gj3su-.*`)
+       c.Check(resp.Scopes, check.DeepEquals, []string{"all"})
 
        authinfo := getCallbackAuthInfo(c, s.railsSpy)
        c.Check(authinfo.Email, check.Equals, u+"@"+s.cluster.Login.PAMDefaultEmailDomain)