Skip to content

Commit dc1a443

Browse files
committed
fix: catch when hydra consent registration fails
1 parent a751a3c commit dc1a443

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

obsidian/impl/v1/utils.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ package obsidianimplv1
3232

3333
import (
3434
"context"
35+
3536
"github.com/gogo/status"
3637
client "github.com/ory/hydra-client-go/v2"
3738
"peridot.resf.org/utils"
@@ -43,6 +44,7 @@ import (
4344
const (
4445
authError = "auth_error"
4546
noUser = "no_user"
47+
badConsent = "bad_consent"
4648
)
4749

4850
func (s *Server) ProcessLoginRequest(challenge string) (*obsidianpb.SessionStatusResponse, error) {
@@ -104,7 +106,6 @@ func (s *Server) AcceptConsentRequest(ctx context.Context, challenge string, con
104106
consent, _, err := s.hydra.OAuth2API.AcceptOAuth2ConsentRequest(ctx).
105107
ConsentChallenge(challenge).
106108
AcceptOAuth2ConsentRequest(client.AcceptOAuth2ConsentRequest{
107-
Context: ctx,
108109
Remember: utils.Pointer[bool](true),
109110
GrantScope: consentReq.RequestedScope,
110111
GrantAccessTokenAudience: consentReq.RequestedAccessTokenAudience,
@@ -121,6 +122,11 @@ func (s *Server) AcceptConsentRequest(ctx context.Context, challenge string, con
121122
},
122123
}).Execute()
123124

125+
if err != nil {
126+
s.log.Error(err)
127+
return nil, status.Error(codes.Internal, badConsent)
128+
}
129+
124130
return &obsidianpb.SessionStatusResponse{
125131
Valid: true,
126132
RedirectUrl: consent.RedirectTo,

0 commit comments

Comments
 (0)