Skip to main content

keycloak_crd/crd/
client.rs

1/*
2 * Copyright (c) 2020 Jens Reimann and others.
3 *
4 * See the NOTICE file(s) distributed with this work for additional
5 * information regarding copyright ownership.
6 *
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
10 *
11 * SPDX-License-Identifier: EPL-2.0
12 */
13
14use k8s_openapi::apimachinery::pkg::apis::meta::v1::LabelSelector;
15use kube_derive::CustomResource;
16use serde::{Deserialize, Serialize};
17use std::collections::BTreeMap;
18
19#[derive(CustomResource, Serialize, Default, Deserialize, Debug, Clone, PartialEq)]
20#[kube(
21    group = "keycloak.org",
22    version = "v1alpha1",
23    kind = "KeycloakClient",
24    namespaced,
25    derive = "Default",
26    derive = "PartialEq",
27    status = "KeycloakClientStatus"
28)]
29#[kube(apiextensions = "v1beta1")]
30#[serde(default, rename_all = "camelCase")]
31pub struct KeycloakClientSpec {
32    pub client: Client,
33    pub realm_selector: LabelSelector,
34}
35
36#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
37#[serde(default, rename_all = "camelCase")]
38pub struct Client {
39    #[serde(skip_serializing_if = "BTreeMap::is_empty")]
40    pub access: BTreeMap<String, bool>,
41    #[serde(skip_serializing_if = "String::is_empty")]
42    pub admin_url: String,
43    #[serde(skip_serializing_if = "BTreeMap::is_empty")]
44    pub attributes: BTreeMap<String, String>,
45    #[serde(skip_serializing_if = "String::is_empty")]
46    pub base_url: String,
47    pub bearer_only: bool,
48    #[serde(skip_serializing_if = "String::is_empty")]
49    pub client_authenticator_type: String,
50    pub client_id: String,
51    pub consent_required: bool,
52    #[serde(skip_serializing_if = "Vec::is_empty")]
53    pub default_roles: Vec<String>,
54    #[serde(skip_serializing_if = "String::is_empty")]
55    pub description: String,
56    pub direct_access_grants_enabled: bool,
57    pub enabled: bool,
58    pub frontchannel_logout: bool,
59    pub full_scope_allowed: bool,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub id: Option<String>,
62    pub implicit_flow_enabled: bool,
63    #[serde(skip_serializing_if = "String::is_empty")]
64    pub name: String,
65    pub node_registration_timeout: i32,
66    pub not_before: i32,
67    #[serde(skip_serializing_if = "String::is_empty")]
68    pub protocol: String,
69    #[serde(skip_serializing_if = "Vec::is_empty")]
70    pub protocol_mappers: Vec<ProtocolMapper>,
71    pub public_client: bool,
72    #[serde(skip_serializing_if = "Vec::is_empty")]
73    pub redirect_uris: Vec<String>,
74    #[serde(skip_serializing_if = "String::is_empty")]
75    pub root_url: String,
76    #[serde(skip_serializing_if = "String::is_empty")]
77    pub secret: String,
78    pub service_accounts_enabled: bool,
79    pub standard_flow_enabled: bool,
80    pub surrogate_auth_required: bool,
81    pub use_template_config: bool,
82    pub use_template_mappers: bool,
83    pub use_template_scope: bool,
84    #[serde(skip_serializing_if = "Vec::is_empty")]
85    pub web_origins: Vec<String>,
86}
87
88#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
89#[serde(default, rename_all = "camelCase")]
90pub struct ProtocolMapper {
91    #[serde(skip_serializing_if = "BTreeMap::is_empty")]
92    pub config: BTreeMap<String, String>,
93    pub consent_required: bool,
94    #[serde(skip_serializing_if = "String::is_empty")]
95    pub consent_text: String,
96    #[serde(skip_serializing_if = "String::is_empty")]
97    pub id: String,
98    #[serde(skip_serializing_if = "String::is_empty")]
99    pub name: String,
100    #[serde(skip_serializing_if = "String::is_empty")]
101    pub protocol: String,
102    #[serde(skip_serializing_if = "String::is_empty")]
103    pub protocol_mapper: String,
104}
105
106#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
107#[serde(default, rename_all = "camelCase")]
108pub struct KeycloakClientStatus {
109    pub phase: String,
110    pub message: String,
111    pub ready: bool,
112}