From 5779508a51fedf22ba88e3545fcafa21d26c595d Mon Sep 17 00:00:00 2001 From: Brenno Oliveira Date: Sat, 19 Oct 2024 21:14:20 +0200 Subject: [PATCH 1/2] Introduce Okta SDK V5 Signed-off-by: Brenno Oliveira --- go.mod | 22 ++++++++---- go.sum | 62 ++++++++++++++++++++++++++++------ providers/okta/app_oauth.go | 38 +++++++++------------ providers/okta/app_swa.go | 54 ++++++++++++++--------------- providers/okta/okta_service.go | 38 ++++++++++++++++----- providers/okta/user.go | 23 ++++++------- 6 files changed, 149 insertions(+), 88 deletions(-) diff --git a/go.mod b/go.mod index ac705d93b9..3a7b82485b 100644 --- a/go.mod +++ b/go.mod @@ -257,7 +257,7 @@ require ( github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.1.0 // indirect github.com/google/jsonapi v1.0.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -310,7 +310,7 @@ require ( github.com/sirupsen/logrus v1.8.1 // indirect github.com/sourcegraph/jsonrpc2 v0.0.0-20210201082850-366fbb520750 // indirect github.com/spf13/afero v1.2.2 // indirect - github.com/stretchr/testify v1.8.2 // indirect + github.com/stretchr/testify v1.9.0 // indirect github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect github.com/ulikunitz/xz v0.5.10 // indirect github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect @@ -321,12 +321,12 @@ require ( github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect go.mongodb.org/mongo-driver v1.7.5 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/net v0.15.0 // indirect + golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/term v0.15.0 // indirect + golang.org/x/sys v0.18.0 // indirect + golang.org/x/term v0.18.0 // indirect golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect golang.org/x/tools v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect @@ -372,16 +372,25 @@ require ( github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/aws/aws-sdk-go v1.44.122 // indirect github.com/clbanning/mxj v1.8.4 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/emicklei/go-restful v2.16.0+incompatible // indirect + github.com/go-jose/go-jose/v3 v3.0.3 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.5 // indirect github.com/go-openapi/swag v0.19.14 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/s2a-go v0.1.4 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect + github.com/lestrrat-go/blackmagic v1.0.2 // indirect + github.com/lestrrat-go/httpcc v1.0.1 // indirect + github.com/lestrrat-go/iter v1.0.2 // indirect + github.com/lestrrat-go/jwx v1.2.29 // indirect + github.com/lestrrat-go/option v1.0.1 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/manicminer/hamilton-autorest v0.2.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -399,6 +408,7 @@ require ( github.com/ionos-cloud/sdk-go-dataplatform v1.0.1 github.com/ionos-cloud/sdk-go-dns v1.1.1 github.com/ionos-cloud/sdk-go-logging v1.0.1 + github.com/okta/okta-sdk-golang/v5 v5.0.1 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.392 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cbs v1.0.392 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cdb v1.0.392 diff --git a/go.sum b/go.sum index 31eccc180f..de3b11c780 100644 --- a/go.sum +++ b/go.sum @@ -630,6 +630,9 @@ github.com/ddelnano/terraform-provider-mikrotik/client v0.0.0-20210401060029-7f6 github.com/ddelnano/terraform-provider-mikrotik/client v0.0.0-20210401060029-7f652169b2c4/go.mod h1:JrRtRlTHCkdIr7OTHCAonKS2yWwmwdqnvf+JEy+OYAA= github.com/ddelnano/terraform-provider-xenorchestra/client v0.0.0-20210401070256-0d721c6762ef h1:q/XC0MjIz8cl/NtyKKewDns6mNd2cUzLQ5Xnh+jGoRg= github.com/ddelnano/terraform-provider-xenorchestra/client v0.0.0-20210401070256-0d721c6762ef/go.mod h1:1T10mQuoIeT4CXsvyc1G1m/+L7mWv6p7cBwmAut/uB0= +github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/denisenkom/go-mssqldb v0.10.0 h1:QykgLZBorFE95+gO3u9esLd0BmbvpWp0/waNNZfHBM8= github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denverdino/aliyungo v0.0.0-20200327235253-d59c209c7e93 h1:ujQ4DKs+MqFWy/hoLAU4Ey/nQhqJ6pXyocMDbVJ4qSw= @@ -698,6 +701,8 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k= +github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -770,6 +775,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d h1:k544nNVphXK4Yt0FTduvOvCfJabEY/DMkdNw0zpCwBE= github.com/gocql/gocql v0.0.0-20210707082121-9a3953d1826d/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= @@ -893,8 +900,9 @@ github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkj github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= @@ -1073,6 +1081,8 @@ github.com/ionos-cloud/sdk-go-logging v1.0.1 h1:MB9jPoBUL3mZ+ois7kXYy67x0FopAw2a github.com/ionos-cloud/sdk-go-logging v1.0.1/go.mod h1:P2JQJpUgH3ZyfyJmv6jMwcB1NJIVVZSL+/bllhWpwc8= github.com/ionos-cloud/sdk-go/v6 v6.1.3 h1:vb6yqdpiqaytvreM0bsn2pXw+1YDvEk2RKSmBAQvgDQ= github.com/ionos-cloud/sdk-go/v6 v6.1.3/go.mod h1:Ox3W0iiEz0GHnfY9e5LmAxwklsxguuNFEUSu0gVRTME= +github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc= +github.com/jarcoal/httpmock v1.2.0/go.mod h1:oCoTsnAz4+UoOUIf5lJOWV2QQIW5UoeUI6aM2YnWAZk= github.com/jefferai/jsonx v1.0.1 h1:GvWkLWihoLqDG0BSP45TUQJH9qsINX50PVrFULgpc/I= github.com/jefferai/jsonx v1.0.1/go.mod h1:yFo3l2fcm7cZVHGq3HKLXE+Pd4RWuRjNBDHksM7XekQ= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= @@ -1143,6 +1153,19 @@ github.com/launchdarkly/api-client-go v5.3.0+incompatible/go.mod h1:INGa7NUZYSwV github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A= +github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= +github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k= +github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= +github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= +github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= +github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= +github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= +github.com/lestrrat-go/jwx v1.2.29 h1:QT0utmUJ4/12rmsVQrJ3u55bycPkKqGYuGT4tyRhxSQ= +github.com/lestrrat-go/jwx v1.2.29/go.mod h1:hU8k2l6WF0ncx20uQdOmik/Gjg6E3/wIRtXSNFeZuB8= +github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= +github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/likexian/gokit v0.0.0-20190309162924-0a377eecf7aa/go.mod h1:QdfYv6y6qPA9pbBA2qXtoT8BMKha6UyNbxWGWl/9Jfk= @@ -1268,6 +1291,8 @@ github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/okta/okta-sdk-golang/v2 v2.12.2-0.20220602195034-d7ea6917663f h1:6zPIZb9jjYbKfCdkpjERA6tpQKIiX+4+d4WJ8kEJJ8g= github.com/okta/okta-sdk-golang/v2 v2.12.2-0.20220602195034-d7ea6917663f/go.mod h1:aL3K0likfyLVapi33OsegX+KJf4c6SDapDhlUcXFEvk= +github.com/okta/okta-sdk-golang/v5 v5.0.1 h1:mwFb5udwexoh105EIE6YhgacLIGOFujhNgQ2fhuBsfQ= +github.com/okta/okta-sdk-golang/v5 v5.0.1/go.mod h1:T/vmECtJX33YPZSVD+sorebd8LLhe38Bi/VrFTjgVX0= github.com/okta/terraform-provider-okta v0.0.0-20210924173942-a5a664459d3b h1:ML6q0susBNxEEXZkifQGjY5ILGJHhU0a72Dm2DHEbSg= github.com/okta/terraform-provider-okta v0.0.0-20210924173942-a5a664459d3b/go.mod h1:hVb3TxYi4ibGeUpue2Rqm84YhD/473w0Xv0uIlylUY8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= @@ -1401,8 +1426,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -1413,8 +1439,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/svanharmelen/jsonapi v0.0.0-20180618144545-0c0828c3f16d/go.mod h1:BSTlc8jOjh0niykqEGVXOLXdi9o0r0kR8tCYiMvjFgw= github.com/tencentcloud/tencentcloud-sdk-go v1.0.392/go.mod h1:l8PU0g9KTDkwn6R4F9WbXXSUwRgKs6k7rj52H4uAcM0= @@ -1752,8 +1780,9 @@ golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1864,8 +1893,10 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1910,6 +1941,7 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2000,13 +2032,19 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= -golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2018,6 +2056,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/providers/okta/app_oauth.go b/providers/okta/app_oauth.go index 2031a30ef9..386f79f1b7 100644 --- a/providers/okta/app_oauth.go +++ b/providers/okta/app_oauth.go @@ -15,50 +15,44 @@ package okta import ( - "context" + "fmt" "github.com/GoogleCloudPlatform/terraformer/terraformutils" - "github.com/okta/okta-sdk-golang/v2/okta" + "github.com/okta/okta-sdk-golang/v5/okta" ) type AppOAuthGenerator struct { OktaService } -func (g AppOAuthGenerator) createResources(appList []*okta.Application) []terraformutils.Resource { +func (g *AppOAuthGenerator) createResources(appList []okta.ListApplications200ResponseInner) []terraformutils.Resource { var resources []terraformutils.Resource for _, app := range appList { - resources = append(resources, terraformutils.NewSimpleResource( - app.Id, - normalizeResourceName(app.Id+"_"+app.Name), - "okta_app_oauth", - "okta", - []string{})) + if app.OpenIdConnectApplication != nil { + resources = append(resources, terraformutils.NewSimpleResource( + *app.OpenIdConnectApplication.Id, + normalizeResourceName(*app.OpenIdConnectApplication.Id+"_"+app.OpenIdConnectApplication.Label), + "okta_app_oauth", + "okta", + []string{}, + )) + } } return resources } // Generate Terraform Resources from Okta API, func (g *AppOAuthGenerator) InitResources() error { - ctx, client, e := g.Client() + ctx, client, e := g.ClientV5() if e != nil { return e } - apps, err := getOAuthApplications(ctx, client) + appList, _, err := client.ApplicationAPI.ListApplications(ctx).Filter("name eq \"oidc_client\"").Execute() if err != nil { - return err + return fmt.Errorf("error listing applications: %w", err) } - g.Resources = g.createResources(apps) + g.Resources = g.createResources(appList) return nil } - -func getOAuthApplications(ctx context.Context, client *okta.Client) ([]*okta.Application, error) { - signOnMode := "OPENID_CONNECT" - apps, err := getApplications(ctx, client, signOnMode) - if err != nil { - return nil, err - } - return apps, nil -} diff --git a/providers/okta/app_swa.go b/providers/okta/app_swa.go index a34fe36086..0d05d04403 100644 --- a/providers/okta/app_swa.go +++ b/providers/okta/app_swa.go @@ -15,57 +15,55 @@ package okta import ( - "context" + "fmt" "github.com/GoogleCloudPlatform/terraformer/terraformutils" - "github.com/okta/okta-sdk-golang/v2/okta" + "github.com/okta/okta-sdk-golang/v5/okta" ) type AppSWAGenerator struct { OktaService } -func (g AppSWAGenerator) createResources(appList []*okta.Application) []terraformutils.Resource { +func (g *AppSWAGenerator) createResources(appList []okta.ListApplications200ResponseInner) []terraformutils.Resource { var resources []terraformutils.Resource for _, app := range appList { - resources = append(resources, terraformutils.NewSimpleResource( - app.Id, - normalizeResourceName(app.Id+"_"+app.Name), - "okta_app_swa", - "okta", - []string{})) + if app.BrowserPluginApplication != nil && app.BrowserPluginApplication.Id != nil && app.BrowserPluginApplication.Label != "" { + resources = append(resources, terraformutils.NewSimpleResource( + *app.BrowserPluginApplication.Id, + normalizeResourceName(*app.BrowserPluginApplication.Id+"_"+app.BrowserPluginApplication.Label), + "okta_app_swa", + "okta", + []string{}, + )) + } } return resources } func (g *AppSWAGenerator) InitResources() error { - ctx, client, e := g.Client() - if e != nil { - return e - } - - apps, err := getSWAApplications(ctx, client) + ctx, client, err := g.ClientV5() if err != nil { return err } - g.Resources = g.createResources(apps) - return nil -} - -func getSWAApplications(ctx context.Context, client *okta.Client) ([]*okta.Application, error) { - signOnMode := "BROWSER_PLUGIN" - apps, err := getApplications(ctx, client, signOnMode) + appList, resp, err := client.ApplicationAPI.ListApplications(ctx).Execute() if err != nil { - return nil, err + return fmt.Errorf("error listing applications: %w", err) } - swaApps := []*okta.Application{} - for _, app := range apps { - if app.Name == "template_swa" { - swaApps = append(swaApps, app) + allApplications := appList + + for resp.HasNextPage() { + var nextAppList []okta.ListApplications200ResponseInner + resp, err = resp.Next(&nextAppList) + if err != nil { + return fmt.Errorf("error fetching next page: %w", err) } + + allApplications = append(allApplications, nextAppList...) } - return swaApps, nil + g.Resources = g.createResources(allApplications) + return nil } diff --git a/providers/okta/okta_service.go b/providers/okta/okta_service.go index d44c35e310..49889ffa22 100644 --- a/providers/okta/okta_service.go +++ b/providers/okta/okta_service.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +19,8 @@ import ( "fmt" "github.com/GoogleCloudPlatform/terraformer/terraformutils" - "github.com/okta/okta-sdk-golang/v2/okta" + oktaV2 "github.com/okta/okta-sdk-golang/v2/okta" + oktaV5 "github.com/okta/okta-sdk-golang/v5/okta" "github.com/okta/terraform-provider-okta/sdk" ) @@ -27,17 +28,17 @@ type OktaService struct { //nolint terraformutils.Service } -func (s *OktaService) Client() (context.Context, *okta.Client, error) { +func (s *OktaService) Client() (context.Context, *oktaV2.Client, error) { orgName := s.Args["org_name"].(string) baseURL := s.Args["base_url"].(string) apiToken := s.Args["api_token"].(string) orgURL := fmt.Sprintf("https://%v.%v", orgName, baseURL) - ctx, client, err := okta.NewClient( + ctx, client, err := oktaV2.NewClient( context.Background(), - okta.WithOrgUrl(orgURL), - okta.WithToken(apiToken), + oktaV2.WithOrgUrl(orgURL), + oktaV2.WithToken(apiToken), ) if err != nil { return ctx, nil, err @@ -46,6 +47,25 @@ func (s *OktaService) Client() (context.Context, *okta.Client, error) { return ctx, client, nil } +func (s *OktaService) ClientV5() (context.Context, *oktaV5.APIClient, error) { + orgName := s.Args["org_name"].(string) + baseURL := s.Args["base_url"].(string) + apiToken := s.Args["api_token"].(string) + + orgURL := fmt.Sprintf("https://%v.%v", orgName, baseURL) + + config, err := oktaV5.NewConfiguration( + oktaV5.WithOrgUrl(orgURL), + oktaV5.WithToken(apiToken), + ) + if err != nil { + return nil, nil, err + } + client := oktaV5.NewAPIClient(config) + + return context.Background(), client, nil +} + func (s *OktaService) APISupplementClient() (context.Context, *sdk.APISupplement, error) { baseURL := s.Args["base_url"].(string) orgName := s.Args["org_name"].(string) @@ -53,10 +73,10 @@ func (s *OktaService) APISupplementClient() (context.Context, *sdk.APISupplement orgURL := fmt.Sprintf("https://%v.%v", orgName, baseURL) - ctx, client, err := okta.NewClient( + ctx, client, err := oktaV2.NewClient( context.Background(), - okta.WithOrgUrl(orgURL), - okta.WithToken(apiToken), + oktaV2.WithOrgUrl(orgURL), + oktaV2.WithToken(apiToken), ) if err != nil { return ctx, nil, err diff --git a/providers/okta/user.go b/providers/okta/user.go index 5d4d784e64..421f3bcd83 100644 --- a/providers/okta/user.go +++ b/providers/okta/user.go @@ -16,20 +16,19 @@ package okta import ( "github.com/GoogleCloudPlatform/terraformer/terraformutils" - "github.com/okta/okta-sdk-golang/v2/okta" + "github.com/okta/okta-sdk-golang/v5/okta" ) type UserGenerator struct { OktaService } -func (g UserGenerator) createResources(userList []*okta.User) []terraformutils.Resource { +func (g UserGenerator) createResources(userList []okta.User) []terraformutils.Resource { var resources []terraformutils.Resource for _, user := range userList { - resources = append(resources, terraformutils.NewSimpleResource( - user.Id, - "user_"+user.Id, + user.GetId(), + "user_"+user.GetId(), "okta_user", "okta", []string{})) @@ -38,19 +37,19 @@ func (g UserGenerator) createResources(userList []*okta.User) []terraformutils.R } func (g *UserGenerator) InitResources() error { - ctx, client, e := g.Client() - if e != nil { - return e + ctx, client, err := g.ClientV5() + if err != nil { + return err } - output, resp, err := client.User.ListUsers(ctx, nil) + output, resp, err := client.UserAPI.ListUsers(ctx).Execute() if err != nil { - return e + return err } for resp.HasNextPage() { - var nextUserSet []*okta.User - resp, _ = resp.Next(ctx, &nextUserSet) + var nextUserSet []okta.User + resp, _ = resp.Next(&nextUserSet) output = append(output, nextUserSet...) } From 88b9fc33ae546eb9cecffeb95a5282e9d3e2e71b Mon Sep 17 00:00:00 2001 From: Brenno Oliveira Date: Wed, 23 Oct 2024 12:57:42 +0200 Subject: [PATCH 2/2] update network_zone generator Signed-off-by: Brenno Oliveira --- providers/okta/network_zone.go | 94 ++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/providers/okta/network_zone.go b/providers/okta/network_zone.go index 1c91c92067..383e79da19 100644 --- a/providers/okta/network_zone.go +++ b/providers/okta/network_zone.go @@ -15,74 +15,78 @@ package okta import ( + "fmt" + "github.com/GoogleCloudPlatform/terraformer/terraformutils" - "github.com/okta/okta-sdk-golang/v2/okta" + "github.com/okta/okta-sdk-golang/v5/okta" ) type NetworkZoneGenerator struct { OktaService } -func (g NetworkZoneGenerator) createResources(networkZoneList []*okta.NetworkZone) []terraformutils.Resource { +func (g *NetworkZoneGenerator) createResources(networkZoneList []okta.ListNetworkZones200ResponseInner) []terraformutils.Resource { var resources []terraformutils.Resource + for _, networkZone := range networkZoneList { + var id, name, zoneType *string + + // Handle each type of network zone + switch { + case networkZone.DynamicNetworkZone != nil: + id = networkZone.DynamicNetworkZone.Id + name = &networkZone.DynamicNetworkZone.Name + zoneType = &networkZone.DynamicNetworkZone.Type + case networkZone.EnhancedDynamicNetworkZone != nil: + id = networkZone.EnhancedDynamicNetworkZone.Id + name = &networkZone.EnhancedDynamicNetworkZone.Name + zoneType = &networkZone.EnhancedDynamicNetworkZone.Type + case networkZone.IPNetworkZone != nil: + id = networkZone.IPNetworkZone.Id + name = &networkZone.IPNetworkZone.Name + zoneType = &networkZone.IPNetworkZone.Type + default: + fmt.Println("Unknown or unsupported network zone type encountered") + continue + } - resources = append(resources, terraformutils.NewResource( - networkZone.Id, - networkZone.Name, - "okta_network_zone", - "okta", - map[string]string{ - "name": networkZone.Name, - "type": networkZone.Type, - }, - []string{}, - attributesNetworkZone(networkZone), - )) + // Ensure all required fields are present before creating the resource + if id != nil && *name != "" && *zoneType != "" { + resource := terraformutils.NewSimpleResource( + *id, + normalizeResourceName(*id+"_"+*name), + "okta_network_zone", + "okta", + []string{}, + ) + resources = append(resources, resource) + } } return resources } func (g *NetworkZoneGenerator) InitResources() error { - ctx, client, err := g.Client() + ctx, client, err := g.ClientV5() if err != nil { - return err + return fmt.Errorf("failed to create Okta client: %w", err) } - output, resp, err := client.NetworkZone.ListNetworkZones(ctx, nil) + networkZoneList, resp, err := client.NetworkZoneAPI.ListNetworkZones(ctx).Execute() if err != nil { - return err - } - - for resp.HasNextPage() { - var networkZoneSet []*okta.NetworkZone - resp, _ = resp.Next(ctx, &networkZoneSet) - output = append(output, networkZoneSet...) + return fmt.Errorf("error listing network zones: %w", err) } - g.Resources = g.createResources(output) - return nil -} - -func attributesNetworkZone(networkZone *okta.NetworkZone) map[string]interface{} { - attributes := map[string]interface{}{} - attributes["usage"] = networkZone.Usage + allZones := networkZoneList - if networkZone.Type == "DYNAMIC" { - if networkZone.Locations != nil { - attributes["dynamic_locations"] = networkZone.Locations - } - } else if networkZone.Type == "IP" { - switch { - case networkZone.Proxies != nil && networkZone.Gateways != nil: - attributes["proxies"] = networkZone.Proxies - attributes["gateways"] = networkZone.Gateways - case networkZone.Proxies != nil && networkZone.Gateways == nil: - attributes["proxies"] = networkZone.Proxies - case networkZone.Proxies == nil && networkZone.Gateways != nil: - attributes["gateways"] = networkZone.Gateways + for resp.HasNextPage() { + var nextZoneSet []okta.ListNetworkZones200ResponseInner + resp, err = resp.Next(&nextZoneSet) + if err != nil { + return fmt.Errorf("error fetching next page of network zones: %w", err) } + allZones = append(allZones, nextZoneSet...) } - return attributes + g.Resources = g.createResources(allZones) + return nil }