-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat(core): Add connection to optional remote ers #1601
Draft
elizabethhealy
wants to merge
1
commit into
separate-keycloak-ers-implementation
Choose a base branch
from
mode-for-remote-ers
base: separate-keycloak-ers-implementation
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
mode: all | ||
modeoptions: | ||
remoteERSUrl: http://localhost:8181 | ||
logger: | ||
level: debug | ||
type: text | ||
output: stdout | ||
# DB and Server configurations are defaulted for local development | ||
db: | ||
host: opentdfdb | ||
# port: 5432 | ||
# user: postgres | ||
# password: changeme | ||
# mode: all | ||
services: | ||
kas: | ||
eccertid: e1 | ||
rsacertid: r1 | ||
entityresolution: | ||
url: http://keycloak:8888/auth | ||
clientid: 'tdf-entity-resolution' | ||
clientsecret: 'secret' | ||
realm: 'opentdf' | ||
legacykeycloak: true | ||
inferid: | ||
from: | ||
email: true | ||
username: true | ||
server: | ||
auth: | ||
enabled: true | ||
enforceDPoP: false | ||
public_client_id: 'opentdf-public' | ||
audience: 'http://localhost:8080' | ||
issuer: http://keycloak:8888/auth/realms/opentdf | ||
policy: | ||
## Default policy for all requests | ||
default: #"role:standard" | ||
## Dot notation is used to access nested claims (i.e. realm_access.roles) | ||
claim: # realm_access.roles | ||
## Maps the external role to the opentdf role | ||
## Note: left side is used in the policy, right side is the external role | ||
map: | ||
# standard: opentdf-standard | ||
# admin: opentdf-admin | ||
# org-admin: opentdf-org-admin | ||
|
||
## Custom policy (see examples https://github.com/casbin/casbin/tree/master/examples) | ||
csv: #| | ||
# p, role:org-admin, policy:attributes, *, *, allow | ||
# p, role:org-admin, policy:subject-mappings, *, *, allow | ||
# p, role:org-admin, policy:resource-mappings, *, *, allow | ||
# p, role:org-admin, policy:kas-registry, *, *, allow | ||
# p, role:org-admin, policy:unsafe, *, *, allow | ||
## Custom model (see https://casbin.org/docs/syntax-for-models/) | ||
model: #| | ||
# [request_definition] | ||
# r = sub, res, act, obj | ||
# | ||
# [policy_definition] | ||
# p = sub, res, act, obj, eft | ||
# | ||
# [role_definition] | ||
# g = _, _ | ||
# | ||
# [policy_effect] | ||
# e = some(where (p.eft == allow)) && !some(where (p.eft == deny)) | ||
# | ||
# [matchers] | ||
# m = g(r.sub, p.sub) && globOrRegexMatch(r.res, p.res) && globOrRegexMatch(r.act, p.act) && globOrRegexMatch(r.obj, p.obj) | ||
cors: | ||
enabled: false | ||
# "*" to allow any origin or a specific domain like "https://yourdomain.com" | ||
allowedorigins: | ||
- '*' | ||
# List of methods. Examples: "GET,POST,PUT" | ||
allowedmethods: | ||
- GET | ||
- POST | ||
- PATCH | ||
- PUT | ||
- DELETE | ||
- OPTIONS | ||
# List of headers that are allowed in a request | ||
allowedheaders: | ||
- ACCEPT | ||
- Authorization | ||
- Content-Type | ||
- X-CSRF-Token | ||
# List of response headers that browsers are allowed to access | ||
exposedheaders: | ||
- Link | ||
# Sets whether credentials are included in the CORS request | ||
allowcredentials: true | ||
# Sets the maximum age (in seconds) of a specific CORS preflight request | ||
maxage: 3600 | ||
grpc: | ||
reflectionEnabled: true # Default is false | ||
cryptoProvider: | ||
type: standard | ||
standard: | ||
keys: | ||
- kid: r1 | ||
alg: rsa:2048 | ||
private: /keys/kas-private.pem | ||
cert: /keys/kas-cert.pem | ||
- kid: e1 | ||
alg: ec:secp256r1 | ||
private: /keys/kas-ec-private.pem | ||
cert: /keys/kas-ec-cert.pem | ||
port: 8080 |
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 |
---|---|---|
|
@@ -16,6 +16,8 @@ import ( | |
"github.com/opentdf/platform/service/pkg/serviceregistry" | ||
wellknown "github.com/opentdf/platform/service/wellknownconfiguration" | ||
"golang.org/x/exp/slices" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
const devModeMessage = ` | ||
|
@@ -104,7 +106,7 @@ func Start(f ...StartOptions) error { | |
|
||
var registeredCoreServices []string | ||
|
||
registeredCoreServices, err = registerCoreServices(svcRegistry, cfg.Mode) | ||
registeredCoreServices, err = registerCoreServices(svcRegistry, cfg.Mode, cfg.ModeOptions) | ||
if err != nil { | ||
logger.Error("could not register core services", slog.String("error", err.Error())) | ||
return fmt.Errorf("could not register core services: %w", err) | ||
|
@@ -157,6 +159,14 @@ func Start(f ...StartOptions) error { | |
// Use IPC for the SDK client | ||
sdkOptions = append(sdkOptions, sdk.WithIPC()) | ||
sdkOptions = append(sdkOptions, sdk.WithCustomCoreConnection(otdf.GRPCInProcess.Conn())) | ||
if cfg.ModeOptions.RemoteERSUrl != "" { | ||
conn, err := getNewGRPCConn(cfg.ModeOptions.RemoteERSUrl) | ||
if err != nil { | ||
logger.Error("issue connecting to remote ers", slog.String("error", err.Error())) | ||
return fmt.Errorf("issue connecting to remote ers: %w", err) | ||
} | ||
sdkOptions = append(sdkOptions, sdk.WithCustomEntityResolutionConnection(conn)) | ||
} | ||
|
||
client, err = sdk.New("", sdkOptions...) | ||
if err != nil { | ||
|
@@ -197,6 +207,17 @@ func Start(f ...StartOptions) error { | |
return nil | ||
} | ||
|
||
func getNewGRPCConn(url string) (*grpc.ClientConn, error) { | ||
defaultOptions := []grpc.DialOption{ | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: support dial options in the yaml config |
||
conn, err := grpc.NewClient(url, defaultOptions...) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to dial grpc server: %w", err) | ||
} | ||
return conn, nil | ||
} | ||
|
||
// waitForShutdownSignal blocks until a SIGINT or SIGTERM is received. | ||
func waitForShutdownSignal() { | ||
sigs := make(chan os.Signal, 1) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts if we moved this configuration underneath
SDKConfig
. Trying to think how we could layer in other options for our internal products as well.platform/service/internal/config/config.go
Lines 45 to 58 in c36624c