Skip to content

Commit 5bf31b9

Browse files
backport of commit e3c7aae (#17202)
This pull request was automerged via backport-assistant
1 parent e2abd39 commit 5bf31b9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

nomad/acl_endpoint.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,18 @@ func (a *ACL) UpsertTokens(args *structs.ACLTokenUpsertRequest, reply *structs.A
638638
return err
639639
}
640640

641+
return a.upsertTokens(args, reply, stateSnapshot)
642+
}
643+
644+
// upsertTokens is a method that contains common token upsertion logic without
645+
// the RPC authentication, metrics, etc. Used in other RPC calls that require to
646+
// upsert tokens.
647+
func (a *ACL) upsertTokens(
648+
args *structs.ACLTokenUpsertRequest,
649+
reply *structs.ACLTokenUpsertResponse,
650+
stateSnapshot *state.StateSnapshot,
651+
) error {
652+
641653
// Validate each token
642654
for idx, token := range args.Tokens {
643655

@@ -2773,7 +2785,7 @@ func (a *ACL) OIDCCompleteAuth(
27732785

27742786
var tokenUpsertReply structs.ACLTokenUpsertResponse
27752787

2776-
if err := a.srv.RPC(structs.ACLUpsertTokensRPCMethod, &tokenUpsertRequest, &tokenUpsertReply); err != nil {
2788+
if err := a.upsertTokens(&tokenUpsertRequest, &tokenUpsertReply, stateSnapshot); err != nil {
27772789
return err
27782790
}
27792791

@@ -2921,7 +2933,7 @@ func (a *ACL) Login(args *structs.ACLLoginRequest, reply *structs.ACLLoginRespon
29212933

29222934
var tokenUpsertReply structs.ACLTokenUpsertResponse
29232935

2924-
if err := a.srv.RPC(structs.ACLUpsertTokensRPCMethod, &tokenUpsertRequest, &tokenUpsertReply); err != nil {
2936+
if err := a.upsertTokens(&tokenUpsertRequest, &tokenUpsertReply, stateSnapshot); err != nil {
29252937
return err
29262938
}
29272939

0 commit comments

Comments
 (0)