mcp: authorize request (pt2) (#5586)

This commit is contained in:
Denis Mishin 2025-04-24 15:11:19 -04:00 committed by GitHub
parent 63ccf6ab93
commit 9e4947c62f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 567 additions and 6 deletions

View file

@ -46,7 +46,7 @@ func (storage *Storage) RegisterClient(
return id, nil
}
func (storage *Storage) GetClientByID(
func (storage *Storage) GetClient(
ctx context.Context,
id string,
) (*rfc7591v1.ClientMetadata, error) {
@ -85,3 +85,24 @@ func (storage *Storage) CreateAuthorizationRequest(
}
return id, nil
}
func (storage *Storage) GetAuthorizationRequest(
ctx context.Context,
id string,
) (*oauth21proto.AuthorizationRequest, error) {
v := new(oauth21proto.AuthorizationRequest)
rec, err := storage.client.Get(ctx, &databroker.GetRequest{
Type: protoutil.GetTypeURL(v),
Id: id,
})
if err != nil {
return nil, fmt.Errorf("failed to get authorization request by ID: %w", err)
}
err = anypb.UnmarshalTo(rec.Record.Data, v, proto.UnmarshalOptions{})
if err != nil {
return nil, fmt.Errorf("failed to unmarshal authorization request: %w", err)
}
return v, nil
}