mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 17:58:02 +02:00
[management] allow impersonation via pats (#3739)
This commit is contained in:
parent
dbf81a145e
commit
38ada44a0e
@ -167,6 +167,11 @@ func (m *AuthMiddleware) checkPATFromRequest(r *http.Request, auth []string) (*h
|
|||||||
IsPAT: true,
|
IsPAT: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if impersonate, ok := r.URL.Query()["account"]; ok && len(impersonate) == 1 {
|
||||||
|
userAuth.AccountId = impersonate[0]
|
||||||
|
userAuth.IsChild = ok
|
||||||
|
}
|
||||||
|
|
||||||
return nbcontext.SetUserAuthInRequest(r, userAuth), nil
|
return nbcontext.SetUserAuthInRequest(r, userAuth), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,14 +242,15 @@ func TestAuthMiddleware_Handler_Child(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Valid PAT Token ignores child",
|
name: "Valid PAT Token accesses child",
|
||||||
path: "/test?account=xyz",
|
path: "/test?account=xyz",
|
||||||
authHeader: "Token " + PAT,
|
authHeader: "Token " + PAT,
|
||||||
expectedUserAuth: &nbcontext.UserAuth{
|
expectedUserAuth: &nbcontext.UserAuth{
|
||||||
AccountId: accountID,
|
AccountId: "xyz",
|
||||||
UserId: userID,
|
UserId: userID,
|
||||||
Domain: testAccount.Domain,
|
Domain: testAccount.Domain,
|
||||||
DomainCategory: testAccount.DomainCategory,
|
DomainCategory: testAccount.DomainCategory,
|
||||||
|
IsChild: true,
|
||||||
IsPAT: true,
|
IsPAT: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user