fix(controller/targets): authorize-session should allow h_ ids (#1853)
* fix(controller/targets): authorize-session should allow h_ ids The targets controller previously only allowed hosts from a static catalog since it checked for the ID subtype from the static package. This change validates host ids with the plugin.Subtype as well Fixes: #1850 * test: cover authorize-session with host id Add a regression test to cover the case where an explicit host ID was given when calling AuthorizeSession
This commit is contained in:
1 parent
6166d2240f
commit
bd30ff4140
2 files changed
+7
-1
No files matched your search
@@ -2102,7 +2102,7 @@ func validateAuthorizeSessionRequest(req *pbs.AuthorizeSessionRequest) error {
|
||||
}
|
||||
if req.GetHostId() != "" {
|
||||
switch host.SubtypeFromId(req.GetHostId()) {
|
||||
case static.Subtype:
|
||||
case static.Subtype, plugin.Subtype:
|
||||
default:
|
||||
badFields[globals.HostIdField] = "Incorrectly formatted identifier."
|
||||
}
|
||||
|
||||
@@ -2776,6 +2776,12 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
assert.NotEmpty(t, cmp.Diff(asRes1.GetItem().GetCredentials(), asRes2.GetItem().GetCredentials(), protocmp.Transform()),
|
||||
"the credentials aren't unique per request authorized session")
|
||||
|
||||
_, err = s.AuthorizeSession(ctx, &pbs.AuthorizeSessionRequest{
|
||||
Id: tar.GetPublicId(),
|
||||
HostId: asRes2.GetItem().GetHostId(),
|
||||
})
|
||||
require.NoError(t, err, "session must authorize with explicit host ID")
|
||||
|
||||
wantedHostId := tc.wantedHostId
|
||||
if tc.wantedHostId == "?" {
|
||||
wantedHostId = asRes2.GetItem().GetHostId()
|
||||
|
||||
Reference in new issue
Block a user