mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
core: fix provider not nullable (#21275)
* core: fix provider not nullable Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix more inconsistencies Signed-off-by: Jens Langhammer <jens@goauthentik.io> * idk man Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@@ -48,7 +48,12 @@ class ApplicationSerializer(ModelSerializer):
|
||||
"""Application Serializer"""
|
||||
|
||||
launch_url = SerializerMethodField()
|
||||
provider_obj = ProviderSerializer(source="get_provider", required=False, read_only=True)
|
||||
provider_obj = ProviderSerializer(
|
||||
source="get_provider",
|
||||
required=False,
|
||||
read_only=True,
|
||||
allow_null=True,
|
||||
)
|
||||
backchannel_providers_obj = ProviderSerializer(
|
||||
source="backchannel_providers", required=False, read_only=True, many=True
|
||||
)
|
||||
|
||||
@@ -18,7 +18,10 @@ from authentik.rbac.decorators import permission_required
|
||||
class EnrollmentTokenSerializer(ModelSerializer):
|
||||
|
||||
device_group_obj = DeviceAccessGroupSerializer(
|
||||
source="device_group", read_only=True, required=False
|
||||
source="device_group",
|
||||
read_only=True,
|
||||
required=False,
|
||||
allow_null=True,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
|
||||
@@ -233,7 +233,7 @@ class SAMLMetadataSerializer(PassiveSerializer):
|
||||
"""SAML Provider Metadata serializer"""
|
||||
|
||||
metadata = CharField(read_only=True)
|
||||
download_url = CharField(read_only=True, required=False)
|
||||
download_url = CharField(read_only=True, required=False, allow_null=True)
|
||||
|
||||
|
||||
class SAMLProviderImportSerializer(PassiveSerializer):
|
||||
|
||||
Generated
+13
-11
@@ -25,11 +25,11 @@ type Application struct {
|
||||
// Application's display Name.
|
||||
Name string `json:"name"`
|
||||
// Internal application name, used in URLs.
|
||||
Slug string `json:"slug" validate:"regexp=^[-a-zA-Z0-9_]+$"`
|
||||
Provider NullableInt32 `json:"provider,omitempty"`
|
||||
ProviderObj Provider `json:"provider_obj"`
|
||||
BackchannelProviders []int32 `json:"backchannel_providers,omitempty"`
|
||||
BackchannelProvidersObj []Provider `json:"backchannel_providers_obj"`
|
||||
Slug string `json:"slug" validate:"regexp=^[-a-zA-Z0-9_]+$"`
|
||||
Provider NullableInt32 `json:"provider,omitempty"`
|
||||
ProviderObj NullableProvider `json:"provider_obj"`
|
||||
BackchannelProviders []int32 `json:"backchannel_providers,omitempty"`
|
||||
BackchannelProvidersObj []Provider `json:"backchannel_providers_obj"`
|
||||
// Allow formatting of launch URL
|
||||
LaunchUrl NullableString `json:"launch_url"`
|
||||
// Open launch URL in a new browser tab or window.
|
||||
@@ -52,7 +52,7 @@ type _Application Application
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewApplication(pk string, name string, slug string, providerObj Provider, backchannelProvidersObj []Provider, launchUrl NullableString, metaIconUrl NullableString, metaIconThemedUrls NullableThemedUrls) *Application {
|
||||
func NewApplication(pk string, name string, slug string, providerObj NullableProvider, backchannelProvidersObj []Provider, launchUrl NullableString, metaIconUrl NullableString, metaIconThemedUrls NullableThemedUrls) *Application {
|
||||
this := Application{}
|
||||
this.Pk = pk
|
||||
this.Name = name
|
||||
@@ -189,27 +189,29 @@ func (o *Application) UnsetProvider() {
|
||||
}
|
||||
|
||||
// GetProviderObj returns the ProviderObj field value
|
||||
// If the value is explicit nil, the zero value for Provider will be returned
|
||||
func (o *Application) GetProviderObj() Provider {
|
||||
if o == nil {
|
||||
if o == nil || o.ProviderObj.Get() == nil {
|
||||
var ret Provider
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.ProviderObj
|
||||
return *o.ProviderObj.Get()
|
||||
}
|
||||
|
||||
// GetProviderObjOk returns a tuple with the ProviderObj field value
|
||||
// and a boolean to check if the value has been set.
|
||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||
func (o *Application) GetProviderObjOk() (*Provider, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.ProviderObj, true
|
||||
return o.ProviderObj.Get(), o.ProviderObj.IsSet()
|
||||
}
|
||||
|
||||
// SetProviderObj sets field value
|
||||
func (o *Application) SetProviderObj(v Provider) {
|
||||
o.ProviderObj = v
|
||||
o.ProviderObj.Set(&v)
|
||||
}
|
||||
|
||||
// GetBackchannelProviders returns the BackchannelProviders field value if set, zero value otherwise.
|
||||
@@ -586,7 +588,7 @@ func (o Application) ToMap() (map[string]interface{}, error) {
|
||||
if o.Provider.IsSet() {
|
||||
toSerialize["provider"] = o.Provider.Get()
|
||||
}
|
||||
toSerialize["provider_obj"] = o.ProviderObj
|
||||
toSerialize["provider_obj"] = o.ProviderObj.Get()
|
||||
if !IsNil(o.BackchannelProviders) {
|
||||
toSerialize["backchannel_providers"] = o.BackchannelProviders
|
||||
}
|
||||
|
||||
+15
-13
@@ -22,13 +22,13 @@ var _ MappedNullable = &EnrollmentToken{}
|
||||
|
||||
// EnrollmentToken struct for EnrollmentToken
|
||||
type EnrollmentToken struct {
|
||||
TokenUuid string `json:"token_uuid"`
|
||||
DeviceGroup NullableString `json:"device_group,omitempty"`
|
||||
DeviceGroupObj DeviceAccessGroup `json:"device_group_obj"`
|
||||
Connector string `json:"connector"`
|
||||
Name string `json:"name"`
|
||||
Expiring *bool `json:"expiring,omitempty"`
|
||||
Expires NullableTime `json:"expires,omitempty"`
|
||||
TokenUuid string `json:"token_uuid"`
|
||||
DeviceGroup NullableString `json:"device_group,omitempty"`
|
||||
DeviceGroupObj NullableDeviceAccessGroup `json:"device_group_obj"`
|
||||
Connector string `json:"connector"`
|
||||
Name string `json:"name"`
|
||||
Expiring *bool `json:"expiring,omitempty"`
|
||||
Expires NullableTime `json:"expires,omitempty"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ type _EnrollmentToken EnrollmentToken
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewEnrollmentToken(tokenUuid string, deviceGroupObj DeviceAccessGroup, connector string, name string) *EnrollmentToken {
|
||||
func NewEnrollmentToken(tokenUuid string, deviceGroupObj NullableDeviceAccessGroup, connector string, name string) *EnrollmentToken {
|
||||
this := EnrollmentToken{}
|
||||
this.TokenUuid = tokenUuid
|
||||
this.DeviceGroupObj = deviceGroupObj
|
||||
@@ -123,27 +123,29 @@ func (o *EnrollmentToken) UnsetDeviceGroup() {
|
||||
}
|
||||
|
||||
// GetDeviceGroupObj returns the DeviceGroupObj field value
|
||||
// If the value is explicit nil, the zero value for DeviceAccessGroup will be returned
|
||||
func (o *EnrollmentToken) GetDeviceGroupObj() DeviceAccessGroup {
|
||||
if o == nil {
|
||||
if o == nil || o.DeviceGroupObj.Get() == nil {
|
||||
var ret DeviceAccessGroup
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.DeviceGroupObj
|
||||
return *o.DeviceGroupObj.Get()
|
||||
}
|
||||
|
||||
// GetDeviceGroupObjOk returns a tuple with the DeviceGroupObj field value
|
||||
// and a boolean to check if the value has been set.
|
||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||
func (o *EnrollmentToken) GetDeviceGroupObjOk() (*DeviceAccessGroup, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.DeviceGroupObj, true
|
||||
return o.DeviceGroupObj.Get(), o.DeviceGroupObj.IsSet()
|
||||
}
|
||||
|
||||
// SetDeviceGroupObj sets field value
|
||||
func (o *EnrollmentToken) SetDeviceGroupObj(v DeviceAccessGroup) {
|
||||
o.DeviceGroupObj = v
|
||||
o.DeviceGroupObj.Set(&v)
|
||||
}
|
||||
|
||||
// GetConnector returns the Connector field value
|
||||
@@ -283,7 +285,7 @@ func (o EnrollmentToken) ToMap() (map[string]interface{}, error) {
|
||||
if o.DeviceGroup.IsSet() {
|
||||
toSerialize["device_group"] = o.DeviceGroup.Get()
|
||||
}
|
||||
toSerialize["device_group_obj"] = o.DeviceGroupObj
|
||||
toSerialize["device_group_obj"] = o.DeviceGroupObj.Get()
|
||||
toSerialize["connector"] = o.Connector
|
||||
toSerialize["name"] = o.Name
|
||||
if !IsNil(o.Expiring) {
|
||||
|
||||
+10
-8
@@ -21,8 +21,8 @@ var _ MappedNullable = &SAMLMetadata{}
|
||||
|
||||
// SAMLMetadata SAML Provider Metadata serializer
|
||||
type SAMLMetadata struct {
|
||||
Metadata string `json:"metadata"`
|
||||
DownloadUrl string `json:"download_url"`
|
||||
Metadata string `json:"metadata"`
|
||||
DownloadUrl NullableString `json:"download_url"`
|
||||
AdditionalProperties map[string]interface{}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ type _SAMLMetadata SAMLMetadata
|
||||
// This constructor will assign default values to properties that have it defined,
|
||||
// and makes sure properties required by API are set, but the set of arguments
|
||||
// will change when the set of required properties is changed
|
||||
func NewSAMLMetadata(metadata string, downloadUrl string) *SAMLMetadata {
|
||||
func NewSAMLMetadata(metadata string, downloadUrl NullableString) *SAMLMetadata {
|
||||
this := SAMLMetadata{}
|
||||
this.Metadata = metadata
|
||||
this.DownloadUrl = downloadUrl
|
||||
@@ -72,27 +72,29 @@ func (o *SAMLMetadata) SetMetadata(v string) {
|
||||
}
|
||||
|
||||
// GetDownloadUrl returns the DownloadUrl field value
|
||||
// If the value is explicit nil, the zero value for string will be returned
|
||||
func (o *SAMLMetadata) GetDownloadUrl() string {
|
||||
if o == nil {
|
||||
if o == nil || o.DownloadUrl.Get() == nil {
|
||||
var ret string
|
||||
return ret
|
||||
}
|
||||
|
||||
return o.DownloadUrl
|
||||
return *o.DownloadUrl.Get()
|
||||
}
|
||||
|
||||
// GetDownloadUrlOk returns a tuple with the DownloadUrl field value
|
||||
// and a boolean to check if the value has been set.
|
||||
// NOTE: If the value is an explicit nil, `nil, true` will be returned
|
||||
func (o *SAMLMetadata) GetDownloadUrlOk() (*string, bool) {
|
||||
if o == nil {
|
||||
return nil, false
|
||||
}
|
||||
return &o.DownloadUrl, true
|
||||
return o.DownloadUrl.Get(), o.DownloadUrl.IsSet()
|
||||
}
|
||||
|
||||
// SetDownloadUrl sets field value
|
||||
func (o *SAMLMetadata) SetDownloadUrl(v string) {
|
||||
o.DownloadUrl = v
|
||||
o.DownloadUrl.Set(&v)
|
||||
}
|
||||
|
||||
func (o SAMLMetadata) MarshalJSON() ([]byte, error) {
|
||||
@@ -106,7 +108,7 @@ func (o SAMLMetadata) MarshalJSON() ([]byte, error) {
|
||||
func (o SAMLMetadata) ToMap() (map[string]interface{}, error) {
|
||||
toSerialize := map[string]interface{}{}
|
||||
toSerialize["metadata"] = o.Metadata
|
||||
toSerialize["download_url"] = o.DownloadUrl
|
||||
toSerialize["download_url"] = o.DownloadUrl.Get()
|
||||
|
||||
for key, value := range o.AdditionalProperties {
|
||||
toSerialize[key] = value
|
||||
|
||||
+3
-3
@@ -28,8 +28,8 @@ pub struct Application {
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub provider: Option<Option<i32>>,
|
||||
#[serde(rename = "provider_obj")]
|
||||
pub provider_obj: models::Provider,
|
||||
#[serde(rename = "provider_obj", deserialize_with = "Option::deserialize")]
|
||||
pub provider_obj: Option<models::Provider>,
|
||||
#[serde(
|
||||
rename = "backchannel_providers",
|
||||
skip_serializing_if = "Option::is_none"
|
||||
@@ -71,7 +71,7 @@ impl Application {
|
||||
pk: uuid::Uuid,
|
||||
name: String,
|
||||
slug: String,
|
||||
provider_obj: models::Provider,
|
||||
provider_obj: Option<models::Provider>,
|
||||
backchannel_providers_obj: Vec<models::Provider>,
|
||||
launch_url: Option<String>,
|
||||
meta_icon_url: Option<String>,
|
||||
|
||||
+3
-3
@@ -21,8 +21,8 @@ pub struct EnrollmentToken {
|
||||
skip_serializing_if = "Option::is_none"
|
||||
)]
|
||||
pub device_group: Option<Option<uuid::Uuid>>,
|
||||
#[serde(rename = "device_group_obj")]
|
||||
pub device_group_obj: models::DeviceAccessGroup,
|
||||
#[serde(rename = "device_group_obj", deserialize_with = "Option::deserialize")]
|
||||
pub device_group_obj: Option<models::DeviceAccessGroup>,
|
||||
#[serde(rename = "connector")]
|
||||
pub connector: uuid::Uuid,
|
||||
#[serde(rename = "name")]
|
||||
@@ -41,7 +41,7 @@ pub struct EnrollmentToken {
|
||||
impl EnrollmentToken {
|
||||
pub fn new(
|
||||
token_uuid: uuid::Uuid,
|
||||
device_group_obj: models::DeviceAccessGroup,
|
||||
device_group_obj: Option<models::DeviceAccessGroup>,
|
||||
connector: uuid::Uuid,
|
||||
name: String,
|
||||
) -> EnrollmentToken {
|
||||
|
||||
+3
-3
@@ -15,13 +15,13 @@ use crate::models;
|
||||
pub struct SamlMetadata {
|
||||
#[serde(rename = "metadata")]
|
||||
pub metadata: String,
|
||||
#[serde(rename = "download_url")]
|
||||
pub download_url: String,
|
||||
#[serde(rename = "download_url", deserialize_with = "Option::deserialize")]
|
||||
pub download_url: Option<String>,
|
||||
}
|
||||
|
||||
impl SamlMetadata {
|
||||
/// SAML Provider Metadata serializer
|
||||
pub fn new(metadata: String, download_url: String) -> SamlMetadata {
|
||||
pub fn new(metadata: String, download_url: Option<String>) -> SamlMetadata {
|
||||
SamlMetadata {
|
||||
metadata,
|
||||
download_url,
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ export interface Application {
|
||||
* @type {Provider}
|
||||
* @memberof Application
|
||||
*/
|
||||
readonly providerObj: Provider;
|
||||
readonly providerObj: Provider | null;
|
||||
/**
|
||||
*
|
||||
* @type {Array<number>}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ export interface EnrollmentToken {
|
||||
* @type {DeviceAccessGroup}
|
||||
* @memberof EnrollmentToken
|
||||
*/
|
||||
readonly deviceGroupObj: DeviceAccessGroup;
|
||||
readonly deviceGroupObj: DeviceAccessGroup | null;
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export interface SAMLMetadata {
|
||||
* @type {string}
|
||||
* @memberof SAMLMetadata
|
||||
*/
|
||||
readonly downloadUrl: string;
|
||||
readonly downloadUrl: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33794,6 +33794,7 @@ components:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Provider'
|
||||
readOnly: true
|
||||
nullable: true
|
||||
backchannel_providers:
|
||||
type: array
|
||||
items:
|
||||
@@ -37990,6 +37991,7 @@ components:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/DeviceAccessGroup'
|
||||
readOnly: true
|
||||
nullable: true
|
||||
connector:
|
||||
type: string
|
||||
format: uuid
|
||||
@@ -53167,6 +53169,7 @@ components:
|
||||
download_url:
|
||||
type: string
|
||||
readOnly: true
|
||||
nullable: true
|
||||
required:
|
||||
- download_url
|
||||
- metadata
|
||||
|
||||
@@ -190,7 +190,7 @@ export class SAMLSourceViewPage extends AKElement {
|
||||
<a
|
||||
class="pf-c-button pf-m-primary"
|
||||
target="_blank"
|
||||
href=${ifDefined(this.metadata?.downloadUrl)}
|
||||
href=${ifDefined(this.metadata?.downloadUrl ?? undefined)}
|
||||
>
|
||||
${msg("Download")}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user