Replace Organization.googleWorkspaceOAuth2Scopes with SCIMBridgeTypeInfo
A Google-Workspace-specific field on the generic Organization type was future-hostile: each new SCIM bridge type would need its own top-level field. Replace with a generic SCIMBridgeTypeInfo type queried through Organization.scimBridgeTypes, parallel to the ConnectorProviderInfo pattern in console/v1. ConnectorList looks up the Google Workspace entry from the list and passes its scopes to GoogleWorkspaceConnector as before. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,10 @@ import { GoogleWorkspaceConnector } from "./GoogleWorkspaceConnector";
|
||||
|
||||
const connectorListFragment = graphql`
|
||||
fragment ConnectorListFragment on Organization {
|
||||
googleWorkspaceOAuth2Scopes
|
||||
scimBridgeTypes {
|
||||
type
|
||||
oauth2Scopes
|
||||
}
|
||||
scimConfiguration {
|
||||
...GoogleWorkspaceConnectorFragment
|
||||
}
|
||||
@@ -33,6 +36,9 @@ export function ConnectorList(props: { fKey: ConnectorListFragment$key }) {
|
||||
const data = useFragment<ConnectorListFragment$key>(connectorListFragment, fKey);
|
||||
const { __ } = useTranslate();
|
||||
|
||||
const googleWorkspaceScopes
|
||||
= data.scimBridgeTypes.find(info => info.type === "GOOGLE_WORKSPACE")?.oauth2Scopes ?? [];
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-base font-medium">{__("Identity Provider")}</h2>
|
||||
@@ -43,7 +49,7 @@ export function ConnectorList(props: { fKey: ConnectorListFragment$key }) {
|
||||
</p>
|
||||
<GoogleWorkspaceConnector
|
||||
fKey={data.scimConfiguration ?? null}
|
||||
oauth2Scopes={data.googleWorkspaceOAuth2Scopes}
|
||||
oauth2Scopes={googleWorkspaceScopes}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -250,7 +250,7 @@ type Organization implements Node {
|
||||
): SAMLConfigurationConnection @goField(forceResolver: true)
|
||||
|
||||
scimConfiguration: SCIMConfiguration @goField(forceResolver: true)
|
||||
googleWorkspaceOAuth2Scopes: [String!]! @goField(forceResolver: true)
|
||||
scimBridgeTypes: [SCIMBridgeTypeInfo!]! @goField(forceResolver: true)
|
||||
|
||||
auditLogEntries(
|
||||
first: Int
|
||||
@@ -422,6 +422,11 @@ enum SCIMBridgeType
|
||||
GOOGLE_WORKSPACE @goEnum(value: "go.probo.inc/probo/pkg/coredata.SCIMBridgeTypeGoogleWorkspace")
|
||||
}
|
||||
|
||||
type SCIMBridgeTypeInfo {
|
||||
type: SCIMBridgeType!
|
||||
oauth2Scopes: [String!]!
|
||||
}
|
||||
|
||||
enum SCIMBridgeState
|
||||
@goModel(model: "go.probo.inc/probo/pkg/coredata.SCIMBridgeState") {
|
||||
PENDING @goEnum(value: "go.probo.inc/probo/pkg/coredata.SCIMBridgeStatePending")
|
||||
|
||||
@@ -1334,9 +1334,14 @@ func (r *organizationResolver) ScimConfiguration(ctx context.Context, obj *types
|
||||
return types.NewSCIMConfiguration(config), nil
|
||||
}
|
||||
|
||||
// GoogleWorkspaceOAuth2Scopes is the resolver for the googleWorkspaceOAuth2Scopes field.
|
||||
func (r *organizationResolver) GoogleWorkspaceOAuth2Scopes(ctx context.Context, obj *types.Organization) ([]string, error) {
|
||||
return googleworkspace.OAuth2Scopes, nil
|
||||
// ScimBridgeTypes is the resolver for the scimBridgeTypes field.
|
||||
func (r *organizationResolver) ScimBridgeTypes(ctx context.Context, obj *types.Organization) ([]*types.SCIMBridgeTypeInfo, error) {
|
||||
return []*types.SCIMBridgeTypeInfo{
|
||||
{
|
||||
Type: coredata.SCIMBridgeTypeGoogleWorkspace,
|
||||
Oauth2Scopes: googleworkspace.OAuth2Scopes,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// AuditLogEntries is the resolver for the auditLogEntries field.
|
||||
|
||||
Reference in New Issue
Block a user