-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Schemas] Limit schema service usage to connectors #1563
Comments
hariso
changed the title
Limit schema service usage to connectors
[Schemas] Limit schema service usage to connectors
May 14, 2024
4 tasks
@hariso @lovromazgon apologies I couldn't bring this one home before I took some time off. What I was planning on doing was adding to package plugin
import (
"fmt"
"math/rand"
"os"
"strings"
"time"
"github.com/conduitio/conduit/pkg/plugin/connector"
)
const charset = "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func randomString(length int) string {
rand.New(rand.NewSource(time.Now().UnixNano()))
sb := strings.Builder{}
sb.Grow(length)
for i := 0; i < length; i++ {
sb.WriteByte(charset[rand.Intn(len(charset))])
}
return sb.String()
}
// GetSchemaCookieValue receives the name of the plugin and the version, and registers into the provided context a cookie that will be used later on to validate if this plugin is registered.
// This cookie will be stored in an environment variable
func GetSchemaCookieValue(pluginName, pluginVersion string) (connector.SchemaCookie, error) {
name := strings.ToUpper(fmt.Sprintf("%s_%s", pluginName, pluginVersion))
value := randomString(32)
if err := registerCookie; err != nil {
return connector.SchemaCookie{}, err
}
return connector.SchemaCookie{
Name: name,
Value: value,
}, nil
}
func registerCookie(cookie connector.SchemaCookie) error {
return os.Setenv(cookie.Name, cookie.Value)
} |
@raulb No problems at all, you already did a lot and didn't leave us much work at all! |
This was referenced Jul 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Part of #1560.
The schema service is currently intended to be used by connectors only. To limit the usage of the service to connectors only we should generate a magic cookie that a connector will use to identify itself (can be saved in an environment variable).
We should also run the schema service on a "random" port.
Pull requests:
The text was updated successfully, but these errors were encountered: