Skip to content
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

operator: Allow reduced tenant OIDC authentication requirements #6362

Merged
merged 3 commits into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Main

- [6362](https://github.com/grafana/loki/pull/6362) **periklis**: Allow reduced tenant OIDC authentication requirements
- [6288](https://github.com/grafana/loki/pull/6288) **aminesnow**: Expose only an HTTPS gateway when in openshift mode
- [6195](https://github.com/grafana/loki/pull/6195) **periklis**: Add ruler config support
- [6198](https://github.com/grafana/loki/pull/6198) **periklis**: Add support for custom S3 CA
Expand Down
18 changes: 13 additions & 5 deletions operator/api/v1beta1/lokistack_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,20 @@ type OIDCSpec struct {
IssuerURL string `json:"issuerURL"`
// RedirectURL defines the URL for redirect.
//
// +required
// +kubebuilder:validation:Required
// +optional
// +kubebuilder:validation:Optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Redirect URL"
RedirectURL string `json:"redirectURL"`
GroupClaim string `json:"groupClaim"`
UsernameClaim string `json:"usernameClaim"`
RedirectURL string `json:"redirectURL,omitempty"`
// Group claim field from ID Token
//
// +optional
// +kubebuilder:validation:Optional
GroupClaim string `json:"groupClaim,omitempty"`
// User claim field from ID Token
//
// +optional
// +kubebuilder:validation:Optional
UsernameClaim string `json:"usernameClaim,omitempty"`
}

// AuthenticationSpec defines the oidc configuration per tenant for lokiStack Gateway component.
Expand Down
5 changes: 2 additions & 3 deletions operator/bundle/manifests/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ spec:
authentication.
properties:
groupClaim:
description: Group claim field from ID Token
type: string
issuerURL:
description: IssuerURL defines the URL for issuer.
Expand All @@ -857,13 +858,11 @@ spec:
- name
type: object
usernameClaim:
description: User claim field from ID Token
type: string
required:
- groupClaim
- issuerURL
- redirectURL
- secret
- usernameClaim
type: object
tenantId:
description: TenantID defines the id of the tenant.
Expand Down
5 changes: 2 additions & 3 deletions operator/config/crd/bases/loki.grafana.com_lokistacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ spec:
authentication.
properties:
groupClaim:
description: Group claim field from ID Token
type: string
issuerURL:
description: IssuerURL defines the URL for issuer.
Expand All @@ -852,13 +853,11 @@ spec:
- name
type: object
usernameClaim:
description: User claim field from ID Token
type: string
required:
- groupClaim
- issuerURL
- redirectURL
- secret
- usernameClaim
type: object
tenantId:
description: TenantID defines the id of the tenant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,7 @@ func extractSecret(s *corev1.Secret, tenantName string) (*manifests.TenantSecret
return nil, kverrors.New("missing clientID field", "field", "clientID")
}
clientSecret := s.Data["clientSecret"]
if len(clientSecret) == 0 {
return nil, kverrors.New("missing clientSecret field", "field", "clientSecret")
}
issuerCAPath := s.Data["issuerCAPath"]
if len(issuerCAPath) == 0 {
return nil, kverrors.New("missing issuerCAPath field", "field", "issuerCAPath")
}

return &manifests.TenantSecrets{
TenantName: tenantName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,6 @@ func TestExtractSecret(t *testing.T) {
secret: &corev1.Secret{},
wantErr: true,
},
{
name: "missing clientSecret",
tenantName: "tenant-a",
secret: &corev1.Secret{
Data: map[string][]byte{
"clientID": []byte("test"),
},
},
wantErr: true,
},
{
name: "missing issuerCAPath",
tenantName: "tenant-a",
secret: &corev1.Secret{
Data: map[string][]byte{
"clientID": []byte("test"),
"clientSecret": []byte("test"),
},
},
wantErr: true,
},
{
name: "all set",
tenantName: "tenant-a",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ tenants:
{{- end -}}
{{- end }}
issuerURL: {{ $spec.OIDC.IssuerURL }}
{{ if $spec.OIDC.RedirectURL }}
redirectURL: {{ $spec.OIDC.RedirectURL }}
{{- end -}}
{{ if $spec.OIDC.UsernameClaim }}
usernameClaim: {{ $spec.OIDC.UsernameClaim }}
{{- end -}}
Expand Down