github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/okta/app.go (about) 1 // Copyright 2021 The Terraformer Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package okta 16 17 import ( 18 "context" 19 20 "github.com/okta/okta-sdk-golang/v2/okta" 21 ) 22 23 //NOTE: Okta SDK v2.6.1 ListApplications() method does not support applications by type at this time. So 24 // we have to create the application filter by our self. 25 func getApplications(ctx context.Context, client *okta.Client, signOnMode string) ([]*okta.Application, error) { 26 supportedApps, err := getAllApplications(ctx, client) 27 if err != nil { 28 return nil, err 29 } 30 31 var filterApps []*okta.Application 32 for _, app := range supportedApps { 33 if app.SignOnMode == signOnMode { 34 filterApps = append(filterApps, app) 35 } 36 } 37 return filterApps, nil 38 } 39 40 func getAllApplications(ctx context.Context, client *okta.Client) ([]*okta.Application, error) { 41 apps, resp, err := client.Application.ListApplications(ctx, nil) 42 if err != nil { 43 return nil, err 44 } 45 46 for resp.HasNextPage() { 47 var nextAppSet []okta.App 48 resp, err = resp.Next(ctx, &nextAppSet) 49 if err != nil { 50 return nil, err 51 } 52 apps = append(apps, nextAppSet...) 53 } 54 55 var supportedApps []*okta.Application 56 for _, app := range apps { 57 //NOTE: Okta provider does not support the following app type/name 58 if app.(*okta.Application).Name == "template_wsfed" || 59 app.(*okta.Application).Name == "template_swa_two_page" || 60 app.(*okta.Application).Name == "okta_enduser" || 61 app.(*okta.Application).Name == "okta_browser_plugin" || 62 app.(*okta.Application).Name == "saasure" { 63 continue 64 } 65 supportedApps = append(supportedApps, app.(*okta.Application)) 66 } 67 68 return supportedApps, nil 69 }