github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/okta/okta_provider.go (about) 1 // Copyright 2019 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 "errors" 19 "os" 20 21 "github.com/GoogleCloudPlatform/terraformer/terraformutils" 22 "github.com/GoogleCloudPlatform/terraformer/terraformutils/providerwrapper" 23 ) 24 25 type OktaProvider struct { //nolint 26 terraformutils.Provider 27 orgName string 28 baseURL string 29 apiToken string 30 } 31 32 func (p *OktaProvider) GetProviderData(arg ...string) map[string]interface{} { 33 return map[string]interface{}{ 34 "provider": map[string]interface{}{ 35 "okta": map[string]interface{}{ 36 "version": providerwrapper.GetProviderVersion(p.GetName()), 37 }, 38 }, 39 } 40 } 41 42 func (p *OktaProvider) GetResourceConnections() map[string]map[string][]string { 43 return map[string]map[string][]string{ 44 "alerts": {"alert_notification_endpoints": []string{"alert_notification_endpoints", "id"}}, 45 } 46 } 47 48 func (p *OktaProvider) Init(args []string) error { 49 orgName := os.Getenv("OKTA_ORG_NAME") 50 if orgName == "" { 51 return errors.New("set OKTA_ORG_NAME env var") 52 } 53 p.orgName = orgName 54 55 baseURL := os.Getenv("OKTA_BASE_URL") 56 if baseURL == "" { 57 return errors.New("set OKTA_BASE_URL env var") 58 } 59 p.baseURL = baseURL 60 61 apiToken := os.Getenv("OKTA_API_TOKEN") 62 if apiToken == "" { 63 return errors.New("set OKTA_API_TOKEN env var") 64 } 65 p.apiToken = apiToken 66 67 return nil 68 } 69 70 func (p *OktaProvider) GetName() string { 71 return "okta" 72 } 73 74 func (p *OktaProvider) InitService(serviceName string, verbose bool) error { 75 var isSupported bool 76 if _, isSupported = p.GetSupportedService()[serviceName]; !isSupported { 77 return errors.New(p.GetName() + ": " + serviceName + " is not a supported service") 78 } 79 p.Service = p.GetSupportedService()[serviceName] 80 p.Service.SetName(serviceName) 81 p.Service.SetProviderName(p.GetName()) 82 p.Service.SetVerbose(verbose) 83 p.Service.SetArgs(map[string]interface{}{ 84 "org_name": p.orgName, 85 "base_url": p.baseURL, 86 "api_token": p.apiToken, 87 }) 88 return nil 89 } 90 91 func (p *OktaProvider) GetSupportedService() map[string]terraformutils.ServiceGenerator { 92 return map[string]terraformutils.ServiceGenerator{ 93 "okta_app_three_field": &AppThreeFieldGenerator{}, 94 "okta_app_swa": &AppSWAGenerator{}, 95 "okta_app_secure_password_store": &AppSecurePasswordStoreGenerator{}, 96 "okta_app_basic_auth": &AppBasicAuthGenerator{}, 97 "okta_app_auto_login": &AppAutoLoginGenerator{}, 98 "okta_app_bookmark": &AppBookmarkGenerator{}, 99 "okta_app_saml": &AppSamlGenerator{}, 100 "okta_app_oauth": &AppOAuthGenerator{}, 101 "okta_idp_oidc": &IdpOIDCGenerator{}, 102 "okta_idp_saml": &IdpSAMLGenerator{}, 103 "okta_idp_social": &IdpSocialGenerator{}, 104 "okta_factor": &FactorGenerator{}, 105 "okta_network_zone": &NetworkZoneGenerator{}, 106 "okta_trusted_origin": &TrustedOriginGenerator{}, 107 "okta_user": &UserGenerator{}, 108 "okta_template_sms": &SMSTemplateGenerator{}, 109 "okta_user_type": &UserTypeGenerator{}, 110 "okta_group": &GroupGenerator{}, 111 "okta_group_rule": &GroupRuleGenerator{}, 112 "okta_event_hook": &EventHookGenerator{}, 113 "okta_inline_hook": &EventHookGenerator{}, 114 "okta_policy_password": &PasswordPolicyGenerator{}, 115 "okta_policy_rule_password": &PasswordPolicyRuleGenerator{}, 116 "okta_policy_signon": &SignOnPolicyGenerator{}, 117 "okta_policy_rule_signon": &SignOnPolicyRuleGenerator{}, 118 "okta_policy_mfa": &MFAPolicyGenerator{}, 119 "okta_policy_rule_mfa": &MFAPolicyRuleGenerator{}, 120 "okta_auth_server": &AuthorizationServerGenerator{}, 121 "okta_auth_server_scope": &AuthorizationServerScopeGenerator{}, 122 "okta_auth_server_claim": &AuthorizationServerClaimGenerator{}, 123 "okta_auth_server_policy": &AuthorizationServerPolicyGenerator{}, 124 "okta_user_schema": &UserSchemaPropertyGenerator{}, 125 "okta_app_user_schema": &AppUserSchemaPropertyGenerator{}, 126 } 127 }