-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(integration): identify supported OAuth integrations through glob…
…al secrets (#791) Because - We want to let CE users set up OAuth configuration for components. - Until now, OAuth was considered as supported based on the component definition. This commit - Consider OAuth supported when both the component definition and the component global secrets have a complete OAuth configuration.
- Loading branch information
Showing
14 changed files
with
216 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package base | ||
|
||
// OAuthConnector contains the OAuth configuration that a comopnent can use to | ||
// support OAuth 2.0 connections. Such components must have an | ||
// `instillOAuthConfig` object in their setup definition. | ||
type OAuthConnector struct { | ||
oAuthClientID string | ||
oAuthClientSecret string | ||
} | ||
|
||
const ( | ||
cfgOAuthClientID = "oauth-client-id" | ||
cfgOAuthClientSecret = "oauth-client-secret" | ||
) | ||
|
||
// WithOAuthConfig loads the OAuth 2.0 connection details into the connector, | ||
// which can be used to determine if the Instill AI deployment supports OAuth | ||
// connections for a given component. | ||
// TODO jvallesm: this is a prerequisite for supporting refresh token when the | ||
// component execution uses an OAuth connection. | ||
func (c *OAuthConnector) WithOAuthConfig(s map[string]any) { | ||
c.oAuthClientID = ReadFromGlobalConfig(cfgOAuthClientID, s) | ||
c.oAuthClientSecret = ReadFromGlobalConfig(cfgOAuthClientSecret, s) | ||
|
||
} | ||
|
||
// SupportsOAuth checks whether the connector is configured to support OAuth. | ||
func (c *OAuthConnector) SupportsOAuth() bool { | ||
return c.oAuthClientID != "" && c.oAuthClientSecret != "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.