Show reconnect when access-review connectors need new OAuth scopes
Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
@@ -493,6 +493,11 @@ func (r *accessReviewSourceResolver) NeedsConfiguration(ctx context.Context, obj
|
||||
}
|
||||
|
||||
// ConnectionStatus is the resolver for the connectionStatus field.
|
||||
//
|
||||
// Returns RECONNECT_REQUIRED when the connector's stored OAuth grant is
|
||||
// missing scopes required by the current provider registration (e.g. a newly
|
||||
// added Graph permission), DISCONNECTED when the credential probe fails, and
|
||||
// CONNECTED when the grant is usable as-is.
|
||||
func (r *accessReviewSourceResolver) ConnectionStatus(ctx context.Context, obj *types.AccessReviewSource) (types.AccessReviewSourceConnectionStatus, error) {
|
||||
if obj.ConnectorID == nil {
|
||||
return types.AccessReviewSourceConnectionStatusNotApplicable, nil
|
||||
@@ -520,6 +525,21 @@ func (r *accessReviewSourceResolver) ConnectionStatus(ctx context.Context, obj *
|
||||
return types.AccessReviewSourceConnectionStatusDisconnected, nil
|
||||
}
|
||||
|
||||
needsReconnect, err := r.accessReview.SourceNeedsReconnect(ctx, scope, *obj.ConnectorID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return types.AccessReviewSourceConnectionStatusNotApplicable, nil
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot determine access source reconnect requirement", log.Error(err))
|
||||
|
||||
return types.AccessReviewSourceConnectionStatusNotApplicable, gqlutils.Internal(ctx)
|
||||
}
|
||||
|
||||
if needsReconnect {
|
||||
return types.AccessReviewSourceConnectionStatusReconnectRequired, nil
|
||||
}
|
||||
|
||||
return types.AccessReviewSourceConnectionStatusConnected, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -247,6 +247,7 @@ input AccessReviewCampaignSourceFetchAttemptOrder {
|
||||
enum AccessReviewSourceConnectionStatus {
|
||||
CONNECTED
|
||||
DISCONNECTED
|
||||
RECONNECT_REQUIRED
|
||||
NOT_APPLICABLE
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user