Skip to content

Commit

Permalink
Merge pull request #51 from canonical/IAM-868
Browse files Browse the repository at this point in the history
Patch Kratos
  • Loading branch information
nsklikas authored Jun 13, 2024
2 parents 1806061 + 240bc11 commit 51c20a3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
22 changes: 22 additions & 0 deletions kratos.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/hydra/hydra.go b/hydra/hydra.go
index a4466307e..915489545 100644
--- a/hydra/hydra.go
+++ b/hydra/hydra.go
@@ -72,7 +72,7 @@ func (h *DefaultHydra) getAdminURL(ctx context.Context) (string, error) {
return u.String(), nil
}

-func (h *DefaultHydra) getAdminAPIClient(ctx context.Context) (*hydraclientgo.OAuth2ApiService, error) {
+func (h *DefaultHydra) getAdminAPIClient(ctx context.Context) (*hydraclientgo.OAuth2APIService, error) {
url, err := h.getAdminURL(ctx)
if err != nil {
return nil, err
@@ -87,7 +87,7 @@ func (h *DefaultHydra) getAdminAPIClient(ctx context.Context) (*hydraclientgo.OA
}

configuration.HTTPClient = client
- return hydraclientgo.NewAPIClient(configuration).OAuth2Api, nil
+ return hydraclientgo.NewAPIClient(configuration).OAuth2API.(*hydraclientgo.OAuth2APIService), nil
}

func (h *DefaultHydra) AcceptLoginRequest(ctx context.Context, params AcceptLoginRequestParams) (string, error) {
18 changes: 14 additions & 4 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ parts:
stage-packages:
# This is needed to pipe the stdout/stderr to a file for log forwarding and to update certificates
- coreutils

openssl:
plugin: nil
stage-packages:
Expand All @@ -44,7 +44,7 @@ parts:
mkdir -p $CRAFT_PART_INSTALL/usr/share/ca-certificates/mozilla/
mkdir -p $CRAFT_PART_INSTALL/usr/sbin
mkdir -p $CRAFT_PART_INSTALL/tmp
touch $CRAFT_PART_INSTALL/etc/ssl/certs/ca-certificates.crt
touch $CRAFT_PART_INSTALL/etc/ca-certificates.conf
for cert in /usr/share/ca-certificates/mozilla/* ; do
Expand All @@ -60,7 +60,7 @@ parts:
plugin: nil
stage-packages:
- sed

find:
plugin: nil
stage-packages:
Expand All @@ -73,11 +73,20 @@ parts:
build-snaps:
- go/1.21/stable
build-environment:
- CGO_ENABLED: 0
- CGO_ENABLED: "0"
source: https://github.com/ory/kratos
source-type: git
source-tag: v1.1.0
override-build: |
# Patch the repo and replace the hydra sdk version
# Workaround for https://github.com/ory/kratos/issues/3904
# TODO(nsklikas): Remove when issue is fixed
cp $CRAFT_PROJECT_DIR/kratos.patch .
git apply -v kratos.patch
go mod edit -replace github.com/ory/hydra-client-go/v2=github.com/ory/hydra-client-go/[email protected]
go mod tidy
# Set the necessary flags
src_config_path="github.com/ory/kratos/driver"
build_ver="${src_config_path}/config.Version"
build_hash="${src_config_path}/config.Commit"
Expand All @@ -88,5 +97,6 @@ parts:
-X ${build_hash}=$(git -C "${CRAFT_PART_SRC}" rev-parse HEAD) \
-X ${build_date}=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
# Build the binary
go mod download
go build -ldflags="${go_linker_flags}" -o ${CRAFT_PART_INSTALL}/bin/kratos

0 comments on commit 51c20a3

Please sign in to comment.