From a6785a56fe9d1a2a40fba3a292d6d55a63091486 Mon Sep 17 00:00:00 2001 From: Dan Ramich Date: Mon, 11 Jun 2018 10:08:06 -0700 Subject: [PATCH] Add azureAD config --- apis/management.cattle.io/v3/authn_types.go | 28 +++++++++++++++++-- apis/management.cattle.io/v3/schema/schema.go | 18 ++++++++++++ .../v3public/authn_types.go | 13 +++++++++ .../v3public/schema/public_schema.go | 15 +++++++++- 4 files changed, 71 insertions(+), 3 deletions(-) diff --git a/apis/management.cattle.io/v3/authn_types.go b/apis/management.cattle.io/v3/authn_types.go index e9f0adfa..c1a85c58 100644 --- a/apis/management.cattle.io/v3/authn_types.go +++ b/apis/management.cattle.io/v3/authn_types.go @@ -111,11 +111,35 @@ type GithubConfigTestOutput struct { } type GithubConfigApplyInput struct { - GithubConfig GithubConfig `json:"githubConfig, omitempty"` + GithubConfig GithubConfig `json:"githubConfig,omitempty"` Code string `json:"code,omitempty"` Enabled bool `json:"enabled,omitempty"` } +type AzureADConfig struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + AuthConfig `json:",inline" mapstructure:",squash"` + + Endpoint string `json:"endpoint,omitempty" norman:"default=https://login.microsoftonline.com/,required,notnullable"` + GraphEndpoint string `json:"graphEndpoint,omitempty" norman:"required,notnullable"` + TokenEndpoint string `json:"tokenEndpoint,omitempty" norman:"required,notnullable"` + AuthEndpoint string `json:"authEndpoint,omitempty" norman:"required,notnullable"` + TenantID string `json:"tenantId,omitempty" norman:"required,notnullable"` + ApplicationID string `json:"applicationId,omitempty" norman:"required,notnullable"` + ApplicationSecret string `json:"applicationSecret,omitempty" norman:"required,notnullable,type=password"` + RancherURL string `json:"rancherUrl,omitempty" norman:"required,notnullable"` +} + +type AzureADConfigTestOutput struct { + RedirectURL string `json:"redirectUrl"` +} + +type AzureADConfigApplyInput struct { + Config AzureADConfig `json:"config,omitempty"` + Code string `json:"code,omitempty"` +} + type ActiveDirectoryConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -146,7 +170,7 @@ type ActiveDirectoryConfig struct { } type ActiveDirectoryTestAndApplyInput struct { - ActiveDirectoryConfig ActiveDirectoryConfig `json:"activeDirectoryConfig, omitempty"` + ActiveDirectoryConfig ActiveDirectoryConfig `json:"activeDirectoryConfig,omitempty"` Username string `json:"username"` Password string `json:"password"` Enabled bool `json:"enabled,omitempty"` diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index a2f7d318..19a2da49 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -326,6 +326,24 @@ func authnTypes(schemas *types.Schemas) *types.Schemas { }). MustImport(&Version, v3.GithubConfigTestOutput{}). MustImport(&Version, v3.GithubConfigApplyInput{}). + //AzureAD Config + MustImportAndCustomize(&Version, v3.AzureADConfig{}, func(schema *types.Schema) { + schema.BaseType = "authConfig" + schema.ResourceActions = map[string]types.Action{ + "disable": {}, + "configureTest": { + Input: "azureADConfig", + Output: "azureADConfigTestOutput", + }, + "testAndApply": { + Input: "azureADConfigApplyInput", + }, + } + schema.CollectionMethods = []string{} + schema.ResourceMethods = []string{http.MethodGet, http.MethodPut} + }). + MustImport(&Version, v3.AzureADConfigTestOutput{}). + MustImport(&Version, v3.AzureADConfigApplyInput{}). // Active Directory Config MustImportAndCustomize(&Version, v3.ActiveDirectoryConfig{}, func(schema *types.Schema) { schema.BaseType = "authConfig" diff --git a/apis/management.cattle.io/v3public/authn_types.go b/apis/management.cattle.io/v3public/authn_types.go index dce3fa1b..2fac12da 100644 --- a/apis/management.cattle.io/v3public/authn_types.go +++ b/apis/management.cattle.io/v3public/authn_types.go @@ -49,3 +49,16 @@ type ActiveDirectoryProvider struct { DefaultLoginDomain string `json:"defaultLoginDomain,omitempty"` } + +type AzureADProvider struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + AuthProvider `json:",inline"` + + RedirectURL string `json:"redirectUrl"` +} + +type AzureADLogin struct { + GenericLogin `json:",inline"` + Code string `json:"code" norman:"type=string,required"` +} diff --git a/apis/management.cattle.io/v3public/schema/public_schema.go b/apis/management.cattle.io/v3public/schema/public_schema.go index 00d4050a..0ae97853 100644 --- a/apis/management.cattle.io/v3public/schema/public_schema.go +++ b/apis/management.cattle.io/v3public/schema/public_schema.go @@ -67,5 +67,18 @@ func authProvidersTypes(schemas *types.Schemas) *types.Schemas { } schema.CollectionMethods = []string{} schema.ResourceMethods = []string{http.MethodGet} - }) + }). + // Azure AD provider + MustImportAndCustomize(&PublicVersion, v3public.AzureADProvider{}, func(schema *types.Schema) { + schema.BaseType = "authProvider" + schema.ResourceActions = map[string]types.Action{ + "login": { + Input: "azureADLogin", + Output: "token", + }, + } + schema.CollectionMethods = []string{} + schema.ResourceMethods = []string{http.MethodGet} + }). + MustImport(&PublicVersion, v3public.AzureADLogin{}) }