@@ -386,9 +386,9 @@ func (s *Session) NewAgentChannel(name string, seat int) (*AgentChannel, error)
386
386
return a , nil
387
387
}
388
388
389
- func (s * Session ) checkFirewall () (bool , error ) {
389
+ func (s * Session ) checkFirewall (ctx context. Context ) (bool , error ) {
390
390
// TODO: Refactor firewall evaluation to remove the map requirement.
391
- if err := s .api .FirewallEvaluate (context . TODO () , map [string ]string {
391
+ if err := s .api .FirewallEvaluate (ctx , map [string ]string {
392
392
"domain" : s .Namespace .Name ,
393
393
"name" : s .Device .Name ,
394
394
"username" : s .Target .Username ,
@@ -417,8 +417,8 @@ func (s *Session) checkFirewall() (bool, error) {
417
417
return true , nil
418
418
}
419
419
420
- func (s * Session ) checkBilling () (bool , error ) {
421
- device , err := s .api .GetDevice (context . TODO () , s .Device .UID )
420
+ func (s * Session ) checkBilling (ctx context. Context ) (bool , error ) {
421
+ device , err := s .api .GetDevice (ctx , s .Device .UID )
422
422
if err != nil {
423
423
defer log .WithError (err ).WithFields (log.Fields {
424
424
"uid" : s .UID ,
@@ -446,8 +446,8 @@ func (s *Session) checkBilling() (bool, error) {
446
446
}
447
447
448
448
// registerAPISession registers a new session on the API.
449
- func (s * Session ) register () error {
450
- err := s .api .SessionCreate (context . TODO () , requests.SessionCreate {
449
+ func (s * Session ) register (ctx context. Context ) error {
450
+ err := s .api .SessionCreate (ctx , requests.SessionCreate {
451
451
UID : s .UID ,
452
452
DeviceUID : s .Device .UID ,
453
453
Username : s .Target .Username ,
@@ -469,10 +469,10 @@ func (s *Session) register() error {
469
469
// Authenticate marks the session as authenticated on the API.
470
470
//
471
471
// It returns an error if authentication fails.
472
- func (s * Session ) authenticate () error {
472
+ func (s * Session ) authenticate (ctx context. Context ) error {
473
473
value := true
474
474
475
- return s .api .UpdateSession (context . TODO () , s .UID , & models.SessionUpdate {
475
+ return s .api .UpdateSession (ctx , s .UID , & models.SessionUpdate {
476
476
Authenticated : & value ,
477
477
})
478
478
}
@@ -580,12 +580,12 @@ func (s *Session) Evaluate(ctx gliderssh.Context) error {
580
580
snap := getSnapshot (ctx )
581
581
582
582
if envs .IsEnterprise () {
583
- if ok , err := s .checkFirewall (); err != nil || ! ok {
583
+ if ok , err := s .checkFirewall (ctx ); err != nil || ! ok {
584
584
return err
585
585
}
586
586
587
587
if envs .IsCloud () {
588
- if ok , err := s .checkBilling (); err != nil || ! ok {
588
+ if ok , err := s .checkBilling (ctx ); err != nil || ! ok {
589
589
return err
590
590
}
591
591
}
@@ -624,7 +624,7 @@ func (s *Session) Auth(ctx gliderssh.Context, auth Auth) error {
624
624
return err
625
625
}
626
626
627
- if err := sess .register (); err != nil {
627
+ if err := sess .register (ctx ); err != nil {
628
628
return err
629
629
}
630
630
@@ -636,7 +636,7 @@ func (s *Session) Auth(ctx gliderssh.Context, auth Auth) error {
636
636
return err
637
637
}
638
638
639
- if err := sess .authenticate (); err != nil {
639
+ if err := sess .authenticate (ctx ); err != nil {
640
640
return err
641
641
}
642
642
default :
0 commit comments