Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
d-g-town committed May 6, 2024
1 parent 94dad32 commit c1b7a62
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 1 addition & 2 deletions api/server/handlers/user/migrate.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package user

import (
"context"
"fmt"
"net/http"
"strconv"
Expand Down Expand Up @@ -127,7 +126,7 @@ func (u *MigrateUsersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
continue
}

createdIdentity, _, err := u.Config().Ory.IdentityAPI.CreateIdentity(context.WithValue(ctx, ory.ContextAccessToken, u.Config().OryApiKey)).CreateIdentityBody(createIdentityBody).Execute()
createdIdentity, _, err := u.Config().Ory.IdentityAPI.CreateIdentity(u.Config().OryApiKeyContextWrapper(ctx)).CreateIdentityBody(createIdentityBody).Execute()
if err != nil {
migrationErrors[user.ID] = fmt.Sprintf("error creating identity: %s", err.Error())
continue
Expand Down
6 changes: 4 additions & 2 deletions api/server/shared/config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"context"

"github.com/gorilla/sessions"
ory "github.com/ory/client-go"
"github.com/porter-dev/api-contracts/generated/go/porter/v1/porterv1connect"
Expand Down Expand Up @@ -122,8 +124,8 @@ type Config struct {

TelemetryConfig telemetry.TracerConfig

Ory *ory.APIClient
OryApiKey string
Ory *ory.APIClient
OryApiKeyContextWrapper func(ctx context.Context) context.Context
}

type ConfigLoader interface {
Expand Down
5 changes: 4 additions & 1 deletion api/server/shared/config/loader/loader.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package loader

import (
"context"
"encoding/base64"
"errors"
"fmt"
Expand Down Expand Up @@ -396,7 +397,9 @@ func (e *EnvConfigLoader) LoadConfig() (res *config.Config, err error) {
}}

res.Ory = ory.NewAPIClient(c)
res.OryApiKey = InstanceEnvConf.ServerConf.OryApiKey
res.OryApiKeyContextWrapper = func(ctx context.Context) context.Context {
return context.WithValue(ctx, ory.ContextAccessToken, InstanceEnvConf.ServerConf.OryApiKey)
}

return res, nil
}
Expand Down

0 comments on commit c1b7a62

Please sign in to comment.