Compare commits
6 Commits
0.4.0
..
7735f363f0
| Author | SHA1 | Date | |
|---|---|---|---|
|
7735f363f0
|
|||
|
e181c97bcc
|
|||
|
2d9d6f56aa
|
|||
|
fb926c81ee
|
|||
|
bd6a71f541
|
|||
|
442068c1b5
|
@@ -1,7 +1,6 @@
|
|||||||
*
|
*
|
||||||
|
|
||||||
!pkg
|
!pkg
|
||||||
!internal
|
|
||||||
!controller.go
|
!controller.go
|
||||||
!main.go
|
!main.go
|
||||||
!go.mod
|
!go.mod
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ codegen:
|
|||||||
test: test-unit test-coverage
|
test: test-unit test-coverage
|
||||||
|
|
||||||
test-unit:
|
test-unit:
|
||||||
go test ./... -coverprofile=coverage.out
|
go test . -coverprofile=coverage.out
|
||||||
|
|
||||||
test-coverage:
|
test-coverage:
|
||||||
go tool gcov2lcov -infile coverage.out > lcov.info
|
go tool gcov2lcov -infile coverage.out > lcov.info
|
||||||
|
|||||||
@@ -34,11 +34,9 @@ spec:
|
|||||||
invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184
|
invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184
|
||||||
# The external host of your application.
|
# The external host of your application.
|
||||||
external_host: https://example.t00n.de
|
external_host: https://example.t00n.de
|
||||||
# The ID of the outpost, which at current point in time can only be retrieved from Authentik directly. In this example: "Proxy-Forward-Auth-Auto"
|
|
||||||
outpost: e004ffe7-4af6-4ac1-9e9d-522354799e1f
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The ProxyProvider will be created in Authentik and assigned to the configured outpost.
|
The ProxyProvider will be created in Authentik, but will not be assigned to an outpost or an application (Resources are TBD).
|
||||||
|
|
||||||
### Application
|
### Application
|
||||||
|
|
||||||
@@ -56,6 +54,8 @@ spec:
|
|||||||
slug: application-example
|
slug: application-example
|
||||||
# The ID of the provider, which can be retrieved from e.g. the ProxyPRovider via "kubectl get pp proxy-provider-example -o jsonpath='{.status.pk}'"
|
# The ID of the provider, which can be retrieved from e.g. the ProxyPRovider via "kubectl get pp proxy-provider-example -o jsonpath='{.status.pk}'"
|
||||||
provider: 105
|
provider: 105
|
||||||
|
# The ID of the outpost, which at current point in time, can only be retrieved from Authentik directly. This value can also not be updated.
|
||||||
|
outpost: e004ffe7-4af6-4ac1-9e9d-522354799e1f
|
||||||
```
|
```
|
||||||
|
|
||||||
### PolicyBinding
|
### PolicyBinding
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ spec:
|
|||||||
- name: PK
|
- name: PK
|
||||||
type: string
|
type: string
|
||||||
jsonPath: .status.pk
|
jsonPath: .status.pk
|
||||||
- name: Outpost
|
|
||||||
type: string
|
|
||||||
jsonPath: .spec.outpost
|
|
||||||
schema:
|
schema:
|
||||||
openAPIV3Schema:
|
openAPIV3Schema:
|
||||||
type: object
|
type: object
|
||||||
@@ -34,15 +31,11 @@ spec:
|
|||||||
type: string
|
type: string
|
||||||
external_host:
|
external_host:
|
||||||
type: string
|
type: string
|
||||||
outpost:
|
|
||||||
type: string
|
|
||||||
format: uuid
|
|
||||||
required:
|
required:
|
||||||
- name
|
- name
|
||||||
- authorization_flow
|
- authorization_flow
|
||||||
- invalidation_flow
|
- invalidation_flow
|
||||||
- external_host
|
- external_host
|
||||||
- outpost
|
|
||||||
status:
|
status:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ spec:
|
|||||||
authorization_flow: 16896c6d-b326-42d1-8d3f-93f32921962e
|
authorization_flow: 16896c6d-b326-42d1-8d3f-93f32921962e
|
||||||
invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184
|
invalidation_flow: 7acac1ef-19e3-4a6f-8d8d-14ca7031d184
|
||||||
external_host: https://example.t00n.de
|
external_host: https://example.t00n.de
|
||||||
outpost: ce8f74c0-88cd-47fe-96f5-d6507b739ceb
|
outpost: e004ffe7-4af6-4ac1-9e9d-522354799e1f
|
||||||
|
|||||||
@@ -212,12 +212,8 @@ func (c *ProxyProviderController) reconcileUpdate(ctx context.Context, pp *v1alp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r)
|
return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r)
|
||||||
}
|
}
|
||||||
pp.Status.PK = strconv.Itoa(int(resp.Pk))
|
|
||||||
|
|
||||||
err = c.reconcileOutpost(ctx, pp.Spec.Outpost, int32(pk), ReconcileOutpostModeAdd)
|
pp.Status.PK = strconv.Itoa(int(resp.Pk))
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("error when calling `reconcileOutpost`: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.updateProxyProviderStatus(ctx, pp)
|
return c.updateProxyProviderStatus(ctx, pp)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ func TestController_syncHandler_update(t *testing.T) {
|
|||||||
pp.Status.PK = "42"
|
pp.Status.PK = "42"
|
||||||
pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer}
|
pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer}
|
||||||
|
|
||||||
var outpostPartialUpdateCalled bool
|
|
||||||
server := newAuthentikTestServer(t, authentikTestHandlers{
|
server := newAuthentikTestServer(t, authentikTestHandlers{
|
||||||
allRetrieve: func(w http.ResponseWriter, _ *http.Request) {
|
allRetrieve: func(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
|
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
|
||||||
@@ -131,20 +130,6 @@ func TestController_syncHandler_update(t *testing.T) {
|
|||||||
proxyPartialUpdate: func(w http.ResponseWriter, _ *http.Request) {
|
proxyPartialUpdate: func(w http.ResponseWriter, _ *http.Request) {
|
||||||
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
|
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
|
||||||
},
|
},
|
||||||
outpostRetrieve: outpostRetrieveHandler(t, nil),
|
|
||||||
outpostPartialUpdate: func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
outpostPartialUpdateCalled = true
|
|
||||||
var body struct {
|
|
||||||
Providers []int32 `json:"providers"`
|
|
||||||
}
|
|
||||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
|
||||||
t.Fatalf("decode outpost patch body: %v", err)
|
|
||||||
}
|
|
||||||
if !slices.Contains(body.Providers, 42) {
|
|
||||||
t.Fatalf("patched providers = %v, want to contain 42", body.Providers)
|
|
||||||
}
|
|
||||||
writeJSON(t, w, http.StatusOK, map[string]any{"pk": testOutpostID, "providers": body.Providers})
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
t.Cleanup(server.Close)
|
t.Cleanup(server.Close)
|
||||||
|
|
||||||
@@ -155,9 +140,6 @@ func TestController_syncHandler_update(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("syncHandler() error = %v", err)
|
t.Fatalf("syncHandler() error = %v", err)
|
||||||
}
|
}
|
||||||
if !outpostPartialUpdateCalled {
|
|
||||||
t.Fatal("expected Authentik outpost partial update call")
|
|
||||||
}
|
|
||||||
|
|
||||||
got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name)
|
got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name)
|
||||||
if got.Status.PK != "42" {
|
if got.Status.PK != "42" {
|
||||||
|
|||||||
Reference in New Issue
Block a user