git.iko.soy/typeable/oauth2-proxy
on master help sign in
Fix Linting Errors (#1835)

* initial commit: add groups to azure Signed-off-by: andrewphamade@gmail.com <andrewphamade@gmail.com> * fix deprecations and linting errors Signed-off-by: Andrew Hamade <andrewphamade@gmail.com> * remove groups testing from azure provider Signed-off-by: Andrew Hamade <andrewphamade@gmail.com> * fix test error Signed-off-by: Andrew Hamade <andrewphamade@gmail.com> * verify-generate Signed-off-by: Andrew Hamade <andrewphamade@gmail.com> Signed-off-by: andrewphamade@gmail.com <andrewphamade@gmail.com> Signed-off-by: Andrew Hamade <andrewphamade@gmail.com>

commit7fe6384f38d84b9f85f9214897bffd584af75e45 authorAndrew Hamade <115507002+devopstagon@users.noreply.github.com> dateFri 21 Oct 2022, 12:57 (4 years ago) parenta6c8f6f
43 files changed+134−146
docs/docs/configuration/alpha_config.md+3−2 main_test.go+2−3 oauthproxy_test.go+8−9 pkg/apis/options/load.go+5−3 pkg/apis/options/load_test.go+3−4 pkg/apis/options/login_url_parameters.go+3−2 pkg/apis/options/util/util.go+1−2 pkg/apis/options/util/util_test.go+2−3 pkg/apis/sessions/session_state.go+2−3 pkg/app/pagewriter/error_page_test.go+8−8 pkg/app/pagewriter/pagewriter_test.go+14−14 pkg/app/pagewriter/sign_in_page_test.go+5−5 pkg/app/pagewriter/static_pages_test.go+6−6 pkg/app/pagewriter/templates_test.go+5−6 pkg/header/header_suite_test.go+2−3 pkg/http/server.go+1−1 pkg/http/server_test.go+9−9 pkg/providers/util/claim_extractor.go+1−1 pkg/requests/builder.go+1−2 pkg/requests/builder_test.go+3−3 pkg/requests/requests_suite_test.go+2−2 pkg/requests/result.go+3−3 pkg/requests/result_test.go+1−1 pkg/sessions/redis/redis_store.go+2−2 pkg/upstream/upstream_suite_test.go+6−6 pkg/util/util.go+2−2 pkg/util/util_test.go+2−3 pkg/validation/common_test.go+1−2 pkg/validation/options_test.go+1−2 pkg/validation/providers.go+1−2 pkg/watcher/watcher.go+2−2 providers/azure.go+1−1 providers/digitalocean.go+1−1 providers/google.go+1−2 providers/google_test.go−1 providers/keycloak.go+1−1 providers/keycloak_oidc.go+15−14 providers/linkedin.go+1−1 providers/logingov.go+2−2 providers/nextcloud.go+1−1 providers/provider_data.go+2−2 providers/providers_test.go+1−2 validator_test.go+1−2
docs/docs/configuration/alpha_config.md+3−2
@@ -306,7 +306,7 @@ the caller provides it, and no value will be sent otherwise.
306306
307307Examples:
308308
309−A parameter whose value is fixed
309+# A parameter whose value is fixed
310310
311311```
312312name: organization
@@ -354,8 +354,9 @@ as backslash is not considered to be an escape character. Alternatively
354354use the "chomped block" format `|-`:
355355
356356```
357−- pattern: |-
357+ - pattern: |-
358358 ^[^@]*@example\.com$
359+
359360```
360361
361362The hyphen is important, a `|` block would have a trailing newline
main_test.go+2−3
@@ -3,7 +3,6 @@ package main
33import (
44 "errors"
55 "fmt"
6− "io/ioutil"
76 "os"
87 "strings"
98 "time"
@@ -191,7 +190,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
191190
192191 if in.configContent != "" {
193192 By("Writing the config to a temporary file", func() {
194− file, err := ioutil.TempFile("", "oauth2-proxy-test-config-XXXX.cfg")
193+ file, err := os.CreateTemp("", "oauth2-proxy-test-config-XXXX.cfg")
195194 Expect(err).ToNot(HaveOccurred())
196195 defer file.Close()
197196
@@ -204,7 +203,7 @@ redirect_url="http://localhost:4180/oauth2/callback"
204203
205204 if in.alphaConfigContent != "" {
206205 By("Writing the config to a temporary file", func() {
207− file, err := ioutil.TempFile("", "oauth2-proxy-test-alpha-config-XXXX.yaml")
206+ file, err := os.CreateTemp("", "oauth2-proxy-test-alpha-config-XXXX.yaml")
208207 Expect(err).ToNot(HaveOccurred())
209208 defer file.Close()
210209
oauthproxy_test.go+8−9
@@ -6,7 +6,6 @@ import (
66 "encoding/base64"
77 "fmt"
88 "io"
9− "io/ioutil"
109 "net/http"
1110 "net/http/httptest"
1211 "net/url"
@@ -837,9 +836,9 @@ func NewProcessCookieTest(opts ProcessCookieTestOpts, modifiers ...OptionsModifi
837836 }
838837
839838 groups := pcTest.opts.Providers[0].AllowedGroups
840− testProvider.AllowedGroups = make(map[string]struct{}, len(groups))
839+ testProvider.ProviderData.AllowedGroups = make(map[string]struct{}, len(groups))
841840 for _, group := range groups {
842− testProvider.AllowedGroups[group] = struct{}{}
841+ testProvider.ProviderData.AllowedGroups[group] = struct{}{}
843842 }
844843 pcTest.proxy.provider = testProvider
845844
@@ -1043,7 +1042,7 @@ func TestUserInfoEndpointAccepted(t *testing.T) {
10431042
10441043 test.proxy.ServeHTTP(test.rw, test.req)
10451044 assert.Equal(t, http.StatusOK, test.rw.Code)
1046− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1045+ bodyBytes, _ := io.ReadAll(test.rw.Body)
10471046 assert.Equal(t, tc.expectedResponse, string(bodyBytes))
10481047 })
10491048 }
@@ -1094,7 +1093,7 @@ func TestAuthOnlyEndpointAccepted(t *testing.T) {
10941093
10951094 test.proxy.ServeHTTP(test.rw, test.req)
10961095 assert.Equal(t, http.StatusAccepted, test.rw.Code)
1097− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1096+ bodyBytes, _ := io.ReadAll(test.rw.Body)
10981097 assert.Equal(t, "", string(bodyBytes))
10991098}
11001099
@@ -1106,7 +1105,7 @@ func TestAuthOnlyEndpointUnauthorizedOnNoCookieSetError(t *testing.T) {
11061105
11071106 test.proxy.ServeHTTP(test.rw, test.req)
11081107 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1109− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1108+ bodyBytes, _ := io.ReadAll(test.rw.Body)
11101109 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
11111110}
11121111
@@ -1126,7 +1125,7 @@ func TestAuthOnlyEndpointUnauthorizedOnExpiration(t *testing.T) {
11261125
11271126 test.proxy.ServeHTTP(test.rw, test.req)
11281127 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1129− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1128+ bodyBytes, _ := io.ReadAll(test.rw.Body)
11301129 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
11311130}
11321131
@@ -1145,7 +1144,7 @@ func TestAuthOnlyEndpointUnauthorizedOnEmailValidationFailure(t *testing.T) {
11451144
11461145 test.proxy.ServeHTTP(test.rw, test.req)
11471146 assert.Equal(t, http.StatusUnauthorized, test.rw.Code)
1148− bodyBytes, _ := ioutil.ReadAll(test.rw.Body)
1147+ bodyBytes, _ := io.ReadAll(test.rw.Body)
11491148 assert.Equal(t, "Unauthorized\n", string(bodyBytes))
11501149}
11511150
@@ -1561,7 +1560,7 @@ func (st *SignatureTest) MakeRequestWithExpectedKey(method, body, key string) er
15611560
15621561 var bodyBuf io.ReadCloser
15631562 if body != "" {
1564− bodyBuf = ioutil.NopCloser(&fakeNetConn{reqBody: body})
1563+ bodyBuf = io.NopCloser(&fakeNetConn{reqBody: body})
15651564 }
15661565 req := httptest.NewRequest(method, "/foo/bar", bodyBuf)
15671566 req.Header = st.header
pkg/apis/options/load.go+5−3
@@ -3,7 +3,7 @@ package options
33import (
44 "errors"
55 "fmt"
6− "io/ioutil"
6+ "os"
77 "reflect"
88 "strings"
99
@@ -17,7 +17,9 @@ import (
1717// variables (prefixed with `OAUTH2_PROXY`) and finally merges in flags from the flagSet.
1818// If a config value is unset and the flag has a non-zero value default, this default will be used.
1919// Eg. A field defined:
20−// FooBar `cfg:"foo_bar" flag:"foo-bar"`
20+//
21+// FooBar `cfg:"foo_bar" flag:"foo-bar"`
22+//
2123// Can be set in the config file as `foo_bar="baz"`, in the environment as `OAUTH2_PROXY_FOO_BAR=baz`,
2224// or via the command line flag `--foo-bar=baz`.
2325func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error {
@@ -147,7 +149,7 @@ func LoadYAML(configFileName string, into interface{}) error {
147149 return errors.New("no configuration file provided")
148150 }
149151
150− data, err := ioutil.ReadFile(configFileName)
152+ data, err := os.ReadFile(configFileName)
151153 if err != nil {
152154 return fmt.Errorf("unable to load config file: %w", err)
153155 }
pkg/apis/options/load_test.go+3−4
@@ -3,7 +3,6 @@ package options
33import (
44 "errors"
55 "fmt"
6− "io/ioutil"
76 "os"
87 "time"
98
@@ -118,7 +117,7 @@ var _ = Describe("Load", func() {
118117
119118 if o.configFile != nil {
120119 By("Creating a config file")
121− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-legacy-config-file")
120+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-legacy-config-file")
122121 Expect(err).ToNot(HaveOccurred())
123122 defer configFile.Close()
124123
@@ -390,7 +389,7 @@ sub:
390389
391390 if in.configFile != nil {
392391 By("Creating a config file")
393− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-config-file")
392+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-config-file")
394393 Expect(err).ToNot(HaveOccurred())
395394 defer configFile.Close()
396395
@@ -488,7 +487,7 @@ injectResponseHeaders:
488487`)
489488
490489 By("Creating a config file")
491− configFile, err := ioutil.TempFile("", "oauth2-proxy-test-alpha-config-file")
490+ configFile, err := os.CreateTemp("", "oauth2-proxy-test-alpha-config-file")
492491 Expect(err).ToNot(HaveOccurred())
493492 defer configFile.Close()
494493
pkg/apis/options/login_url_parameters.go+3−2
@@ -14,7 +14,7 @@ package options
1414//
1515// Examples:
1616//
17−// A parameter whose value is fixed
17+// # A parameter whose value is fixed
1818//
1919// ```
2020// name: organization
@@ -62,8 +62,9 @@ package options
6262// use the "chomped block" format `|-`:
6363//
6464// ```
65−// - pattern: |-
65+// - pattern: |-
6666// ^[^@]*@example\.com$
67+//
6768// ```
6869//
6970// The hyphen is important, a `|` block would have a trailing newline
pkg/apis/options/util/util.go+1−2
@@ -2,7 +2,6 @@ package util
22
33import (
44 "errors"
5− "io/ioutil"
65 "os"
76
87 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -16,7 +15,7 @@ func GetSecretValue(source *options.SecretSource) ([]byte, error) {
1615 case len(source.Value) == 0 && source.FromEnv != "" && source.FromFile == "":
1716 return []byte(os.Getenv(source.FromEnv)), nil
1817 case len(source.Value) == 0 && source.FromEnv == "" && source.FromFile != "":
19− return ioutil.ReadFile(source.FromFile)
18+ return os.ReadFile(source.FromFile)
2019 default:
2120 return nil, errors.New("secret source is invalid: exactly one entry required, specify either value, fromEnv or fromFile")
2221 }
pkg/apis/options/util/util_test.go+2−3
@@ -1,7 +1,6 @@
11package util
22
33import (
4− "io/ioutil"
54 "os"
65 "path"
76
@@ -20,9 +19,9 @@ var _ = Describe("GetSecretValue", func() {
2019 os.Setenv(secretEnvKey, secretEnvValue)
2120
2221 var err error
23− fileDir, err = ioutil.TempDir("", "oauth2-proxy-util-get-secret-value")
22+ fileDir, err = os.MkdirTemp("", "oauth2-proxy-util-get-secret-value")
2423 Expect(err).ToNot(HaveOccurred())
25− Expect(ioutil.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
24+ Expect(os.WriteFile(path.Join(fileDir, "secret-file"), secretFileValue, 0600)).To(Succeed())
2625 })
2726
2827 AfterEach(func() {
pkg/apis/sessions/session_state.go+2−3
@@ -5,7 +5,6 @@ import (
55 "context"
66 "fmt"
77 "io"
8− "io/ioutil"
98 "time"
109
1110 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
@@ -225,7 +224,7 @@ func lz4Compress(payload []byte) ([]byte, error) {
225224 return nil, fmt.Errorf("error closing lz4 writer: %w", err)
226225 }
227226
228− compressed, err := ioutil.ReadAll(buf)
227+ compressed, err := io.ReadAll(buf)
229228 if err != nil {
230229 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
231230 }
@@ -244,7 +243,7 @@ func lz4Decompress(compressed []byte) ([]byte, error) {
244243 return nil, fmt.Errorf("error copying lz4 stream to buffer: %w", err)
245244 }
246245
247− payload, err := ioutil.ReadAll(buf)
246+ payload, err := io.ReadAll(buf)
248247 if err != nil {
249248 return nil, fmt.Errorf("error reading lz4 buffer: %w", err)
250249 }
pkg/app/pagewriter/error_page_test.go+8−8
@@ -3,7 +3,7 @@ package pagewriter
33import (
44 "errors"
55 "html/template"
6− "io/ioutil"
6+ "io"
77 "net/http/httptest"
88
99 middlewareapi "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
@@ -36,7 +36,7 @@ var _ = Describe("Error Page Writer", func() {
3636 AppError: "Access Denied",
3737 })
3838
39− body, err := ioutil.ReadAll(recorder.Result().Body)
39+ body, err := io.ReadAll(recorder.Result().Body)
4040 Expect(err).ToNot(HaveOccurred())
4141 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
4242 })
@@ -50,7 +50,7 @@ var _ = Describe("Error Page Writer", func() {
5050 AppError: "Access Denied",
5151 })
5252
53− body, err := ioutil.ReadAll(recorder.Result().Body)
53+ body, err := io.ReadAll(recorder.Result().Body)
5454 Expect(err).ToNot(HaveOccurred())
5555 Expect(string(body)).To(Equal("Internal Server Error Oops! Something went wrong. For more information contact your server administrator. /prefix/ 500 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
5656 })
@@ -68,7 +68,7 @@ var _ = Describe("Error Page Writer", func() {
6868 },
6969 })
7070
71− body, err := ioutil.ReadAll(recorder.Result().Body)
71+ body, err := io.ReadAll(recorder.Result().Body)
7272 Expect(err).ToNot(HaveOccurred())
7373 Expect(string(body)).To(Equal("Forbidden An extra message: with more context. /prefix/ 403 /redirect 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
7474 })
@@ -82,7 +82,7 @@ var _ = Describe("Error Page Writer", func() {
8282 AppError: "Access Denied",
8383 })
8484
85− body, err := ioutil.ReadAll(recorder.Result().Body)
85+ body, err := io.ReadAll(recorder.Result().Body)
8686 Expect(err).ToNot(HaveOccurred())
8787 Expect(string(body)).To(Equal("Forbidden You do not have permission to access this resource. /prefix/ 403 /redirect &lt;script&gt;alert(1)&lt;/script&gt; Custom Footer Text v0.0.0-test"))
8888 })
@@ -97,7 +97,7 @@ var _ = Describe("Error Page Writer", func() {
9797 recorder := httptest.NewRecorder()
9898 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
9999
100− body, err := ioutil.ReadAll(recorder.Result().Body)
100+ body, err := io.ReadAll(recorder.Result().Body)
101101 Expect(err).ToNot(HaveOccurred())
102102 Expect(string(body)).To(Equal("Bad Gateway There was a problem connecting to the upstream server. /prefix/ 502 11111111-2222-4333-8444-555555555555 Custom Footer Text v0.0.0-test"))
103103 })
@@ -121,7 +121,7 @@ var _ = Describe("Error Page Writer", func() {
121121 AppError: "Debug error",
122122 })
123123
124− body, err := ioutil.ReadAll(recorder.Result().Body)
124+ body, err := io.ReadAll(recorder.Result().Body)
125125 Expect(err).ToNot(HaveOccurred())
126126 Expect(string(body)).To(Equal("Debug error"))
127127 })
@@ -136,7 +136,7 @@ var _ = Describe("Error Page Writer", func() {
136136 recorder := httptest.NewRecorder()
137137 errorPage.ProxyErrorHandler(recorder, req, errors.New("some upstream error"))
138138
139− body, err := ioutil.ReadAll(recorder.Result().Body)
139+ body, err := io.ReadAll(recorder.Result().Body)
140140 Expect(err).ToNot(HaveOccurred())
141141 Expect(string(body)).To(Equal("some upstream error"))
142142 })
pkg/app/pagewriter/pagewriter_test.go+14−14
@@ -3,7 +3,7 @@ package pagewriter
33import (
44 "errors"
55 "fmt"
6− "io/ioutil"
6+ "io"
77 "net/http"
88 "net/http/httptest"
99 "os"
@@ -50,7 +50,7 @@ var _ = Describe("Writer", func() {
5050 AppError: "Some debug error",
5151 })
5252
53− body, err := ioutil.ReadAll(recorder.Result().Body)
53+ body, err := io.ReadAll(recorder.Result().Body)
5454 Expect(err).ToNot(HaveOccurred())
5555 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
5656 })
@@ -59,7 +59,7 @@ var _ = Describe("Writer", func() {
5959 recorder := httptest.NewRecorder()
6060 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
6161
62− body, err := ioutil.ReadAll(recorder.Result().Body)
62+ body, err := io.ReadAll(recorder.Result().Body)
6363 Expect(err).ToNot(HaveOccurred())
6464 Expect(string(body)).To(HavePrefix("\n<!DOCTYPE html>"))
6565 })
@@ -70,14 +70,14 @@ var _ = Describe("Writer", func() {
7070
7171 BeforeEach(func() {
7272 var err error
73− customDir, err = ioutil.TempDir("", "oauth2-proxy-pagewriter-test")
73+ customDir, err = os.MkdirTemp("", "oauth2-proxy-pagewriter-test")
7474 Expect(err).ToNot(HaveOccurred())
7575
7676 templateHTML := `Custom Template`
7777 signInFile := filepath.Join(customDir, signInTemplateName)
78− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
78+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
7979 errorFile := filepath.Join(customDir, errorTemplateName)
80− Expect(ioutil.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
80+ Expect(os.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
8181
8282 opts.TemplatesPath = customDir
8383
@@ -97,7 +97,7 @@ var _ = Describe("Writer", func() {
9797 AppError: "Some debug error",
9898 })
9999
100− body, err := ioutil.ReadAll(recorder.Result().Body)
100+ body, err := io.ReadAll(recorder.Result().Body)
101101 Expect(err).ToNot(HaveOccurred())
102102 Expect(string(body)).To(Equal("Custom Template"))
103103 })
@@ -106,7 +106,7 @@ var _ = Describe("Writer", func() {
106106 recorder := httptest.NewRecorder()
107107 writer.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
108108
109− body, err := ioutil.ReadAll(recorder.Result().Body)
109+ body, err := io.ReadAll(recorder.Result().Body)
110110 Expect(err).ToNot(HaveOccurred())
111111 Expect(string(body)).To(Equal("Custom Template"))
112112 })
@@ -117,12 +117,12 @@ var _ = Describe("Writer", func() {
117117
118118 BeforeEach(func() {
119119 var err error
120− customDir, err = ioutil.TempDir("", "oauth2-proxy-pagewriter-test")
120+ customDir, err = os.MkdirTemp("", "oauth2-proxy-pagewriter-test")
121121 Expect(err).ToNot(HaveOccurred())
122122
123123 templateHTML := `{{ Custom Broken Template`
124124 signInFile := filepath.Join(customDir, signInTemplateName)
125− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
125+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
126126
127127 opts.TemplatesPath = customDir
128128 })
@@ -155,7 +155,7 @@ var _ = Describe("Writer", func() {
155155
156156 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
157157
158− body, err := ioutil.ReadAll(rw.Result().Body)
158+ body, err := io.ReadAll(rw.Result().Body)
159159 Expect(err).ToNot(HaveOccurred())
160160 Expect(string(body)).To(Equal(in.expectedBody))
161161 },
@@ -188,7 +188,7 @@ var _ = Describe("Writer", func() {
188188
189189 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
190190
191− body, err := ioutil.ReadAll(rw.Result().Body)
191+ body, err := io.ReadAll(rw.Result().Body)
192192 Expect(err).ToNot(HaveOccurred())
193193 Expect(string(body)).To(Equal(in.expectedBody))
194194 },
@@ -218,7 +218,7 @@ var _ = Describe("Writer", func() {
218218
219219 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
220220
221− body, err := ioutil.ReadAll(rw.Result().Body)
221+ body, err := io.ReadAll(rw.Result().Body)
222222 Expect(err).ToNot(HaveOccurred())
223223 Expect(string(body)).To(Equal(in.expectedBody))
224224 },
@@ -257,7 +257,7 @@ var _ = Describe("Writer", func() {
257257
258258 Expect(rw.Result().StatusCode).To(Equal(in.expectedStatus))
259259
260− body, err := ioutil.ReadAll(rw.Result().Body)
260+ body, err := io.ReadAll(rw.Result().Body)
261261 Expect(err).ToNot(HaveOccurred())
262262 Expect(string(body)).To(Equal(in.expectedBody))
263263 },
pkg/app/pagewriter/sign_in_page_test.go+5−5
@@ -4,7 +4,7 @@ import (
44 "errors"
55 "fmt"
66 "html/template"
7− "io/ioutil"
7+ "io"
88 "net/http"
99 "net/http/httptest"
1010 "os"
@@ -56,7 +56,7 @@ var _ = Describe("SignIn Page", func() {
5656 recorder := httptest.NewRecorder()
5757 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
5858
59− body, err := ioutil.ReadAll(recorder.Result().Body)
59+ body, err := io.ReadAll(recorder.Result().Body)
6060 Expect(err).ToNot(HaveOccurred())
6161 Expect(string(body)).To(Equal("/prefix/ My Provider Sign In Here Custom Footer Text v0.0.0-test /redirect true Logo Data"))
6262 })
@@ -70,7 +70,7 @@ var _ = Describe("SignIn Page", func() {
7070 recorder := httptest.NewRecorder()
7171 signInPage.WriteSignInPage(recorder, request, "/redirect", http.StatusOK)
7272
73− body, err := ioutil.ReadAll(recorder.Result().Body)
73+ body, err := io.ReadAll(recorder.Result().Body)
7474 Expect(err).ToNot(HaveOccurred())
7575 Expect(string(body)).To(Equal(fmt.Sprintf("Internal Server Error | %s", testRequestID)))
7676 })
@@ -84,12 +84,12 @@ var _ = Describe("SignIn Page", func() {
8484
8585 BeforeEach(func() {
8686 var err error
87− customDir, err = ioutil.TempDir("", "oauth2-proxy-sign-in-page-test")
87+ customDir, err = os.MkdirTemp("", "oauth2-proxy-sign-in-page-test")
8888 Expect(err).ToNot(HaveOccurred())
8989
9090 for _, ext := range []string{".svg", ".png", ".jpg", ".jpeg", ".gif"} {
9191 fileName := filepath.Join(customDir, fmt.Sprintf("logo%s", ext))
92− Expect(ioutil.WriteFile(fileName, []byte(fakeImageData), 0600)).To(Succeed())
92+ Expect(os.WriteFile(fileName, []byte(fakeImageData), 0600)).To(Succeed())
9393 }
9494 })
9595
pkg/app/pagewriter/static_pages_test.go+6−6
@@ -3,7 +3,7 @@ package pagewriter
33import (
44 "errors"
55 "html/template"
6− "io/ioutil"
6+ "io"
77 "net/http"
88 "net/http/httptest"
99 "os"
@@ -27,11 +27,11 @@ var _ = Describe("Static Pages", func() {
2727 template: errorTmpl,
2828 }
2929
30− customDir, err = ioutil.TempDir("", "oauth2-proxy-static-pages-test")
30+ customDir, err = os.MkdirTemp("", "oauth2-proxy-static-pages-test")
3131 Expect(err).ToNot(HaveOccurred())
3232
3333 robotsTxtFile := filepath.Join(customDir, robotsTxtName)
34− Expect(ioutil.WriteFile(robotsTxtFile, []byte(customRobots), 0400)).To(Succeed())
34+ Expect(os.WriteFile(robotsTxtFile, []byte(customRobots), 0400)).To(Succeed())
3535
3636 request = httptest.NewRequest("", "http://127.0.0.1/", nil)
3737 request = middlewareapi.AddRequestScope(request, &middlewareapi.RequestScope{
@@ -58,7 +58,7 @@ var _ = Describe("Static Pages", func() {
5858 recorder := httptest.NewRecorder()
5959 pageWriter.WriteRobotsTxt(recorder, request)
6060
61− body, err := ioutil.ReadAll(recorder.Result().Body)
61+ body, err := io.ReadAll(recorder.Result().Body)
6262 Expect(err).ToNot(HaveOccurred())
6363 Expect(string(body)).To(Equal(customRobots))
6464
@@ -81,7 +81,7 @@ var _ = Describe("Static Pages", func() {
8181 recorder := httptest.NewRecorder()
8282 pageWriter.WriteRobotsTxt(recorder, request)
8383
84− body, err := ioutil.ReadAll(recorder.Result().Body)
84+ body, err := io.ReadAll(recorder.Result().Body)
8585 Expect(err).ToNot(HaveOccurred())
8686 Expect(string(body)).To(Equal(string(defaultRobotsTxt)))
8787
@@ -94,7 +94,7 @@ var _ = Describe("Static Pages", func() {
9494 }
9595 pageWriter.WriteRobotsTxt(recorder, request)
9696
97− body, err := ioutil.ReadAll(recorder.Result().Body)
97+ body, err := io.ReadAll(recorder.Result().Body)
9898 Expect(err).ToNot(HaveOccurred())
9999 Expect(string(body)).To(Equal(string("Internal Server Error")))
100100
pkg/app/pagewriter/templates_test.go+5−6
@@ -3,7 +3,6 @@ package pagewriter
33import (
44 "bytes"
55 "html/template"
6− "io/ioutil"
76 "os"
87 "path/filepath"
98
@@ -16,14 +15,14 @@ var _ = Describe("Templates", func() {
1615
1716 BeforeEach(func() {
1817 var err error
19− customDir, err = ioutil.TempDir("", "oauth2-proxy-templates-test")
18+ customDir, err = os.MkdirTemp("", "oauth2-proxy-templates-test")
2019 Expect(err).ToNot(HaveOccurred())
2120
2221 templateHTML := `{{.TestString}} {{.TestString | ToLower}} {{.TestString | ToUpper}}`
2322 signInFile := filepath.Join(customDir, signInTemplateName)
24− Expect(ioutil.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
23+ Expect(os.WriteFile(signInFile, []byte(templateHTML), 0600)).To(Succeed())
2524 errorFile := filepath.Join(customDir, errorTemplateName)
26− Expect(ioutil.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
25+ Expect(os.WriteFile(errorFile, []byte(templateHTML), 0600)).To(Succeed())
2726 })
2827
2928 AfterEach(func() {
@@ -162,7 +161,7 @@ var _ = Describe("Templates", func() {
162161 Context("With an invalid sign_in template", func() {
163162 BeforeEach(func() {
164163 signInFile := filepath.Join(customDir, signInTemplateName)
165− Expect(ioutil.WriteFile(signInFile, []byte("{{"), 0600))
164+ Expect(os.WriteFile(signInFile, []byte("{{"), 0600))
166165 })
167166
168167 It("Should return an error when loading templates", func() {
@@ -175,7 +174,7 @@ var _ = Describe("Templates", func() {
175174 Context("With an invalid error template", func() {
176175 BeforeEach(func() {
177176 errorFile := filepath.Join(customDir, errorTemplateName)
178− Expect(ioutil.WriteFile(errorFile, []byte("{{"), 0600))
177+ Expect(os.WriteFile(errorFile, []byte("{{"), 0600))
179178 })
180179
181180 It("Should return an error when loading templates", func() {
pkg/header/header_suite_test.go+2−3
@@ -1,7 +1,6 @@
11package header
22
33import (
4− "io/ioutil"
54 "os"
65 "path"
76 "testing"
@@ -26,9 +25,9 @@ func TestHeaderSuite(t *testing.T) {
2625var _ = BeforeSuite(func() {
2726 os.Setenv("SECRET_ENV", "super-secret-env")
2827
29− dir, err := ioutil.TempDir("", "oauth2-proxy-header-suite")
28+ dir, err := os.MkdirTemp("", "oauth2-proxy-header-suite")
3029 Expect(err).ToNot(HaveOccurred())
31− Expect(ioutil.WriteFile(path.Join(dir, "secret-file"), []byte("super-secret-file"), 0644)).To(Succeed())
30+ Expect(os.WriteFile(path.Join(dir, "secret-file"), []byte("super-secret-file"), 0644)).To(Succeed())
3231 filesDir = dir
3332})
3433
pkg/http/server.go+1−1
@@ -186,7 +186,7 @@ func (s *server) Start(ctx context.Context) error {
186186// When the given context is cancelled the server will be shutdown.
187187// If any errors occur, only the first error will be returned.
188188func (s *server) startServer(ctx context.Context, listener net.Listener) error {
189− srv := &http.Server{Handler: s.handler}
189+ srv := &http.Server{Handler: s.handler, ReadHeaderTimeout: time.Minute}
190190 g, groupCtx := errgroup.WithContext(ctx)
191191
192192 g.Go(func() error {
pkg/http/server_test.go+9−9
@@ -4,7 +4,7 @@ import (
44 "context"
55 "errors"
66 "fmt"
7− "io/ioutil"
7+ "io"
88 "net/http"
99
1010 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -565,7 +565,7 @@ var _ = Describe("Server", func() {
565565 Expect(err).ToNot(HaveOccurred())
566566 Expect(resp.StatusCode).To(Equal(http.StatusOK))
567567
568− body, err := ioutil.ReadAll(resp.Body)
568+ body, err := io.ReadAll(resp.Body)
569569 Expect(err).ToNot(HaveOccurred())
570570 Expect(string(body)).To(Equal(hello))
571571 })
@@ -619,7 +619,7 @@ var _ = Describe("Server", func() {
619619 Expect(err).ToNot(HaveOccurred())
620620 Expect(resp.StatusCode).To(Equal(http.StatusOK))
621621
622− body, err := ioutil.ReadAll(resp.Body)
622+ body, err := io.ReadAll(resp.Body)
623623 Expect(err).ToNot(HaveOccurred())
624624 Expect(string(body)).To(Equal(hello))
625625 })
@@ -690,7 +690,7 @@ var _ = Describe("Server", func() {
690690 Expect(err).ToNot(HaveOccurred())
691691 Expect(resp.StatusCode).To(Equal(http.StatusOK))
692692
693− body, err := ioutil.ReadAll(resp.Body)
693+ body, err := io.ReadAll(resp.Body)
694694 Expect(err).ToNot(HaveOccurred())
695695 Expect(string(body)).To(Equal(hello))
696696 })
@@ -705,7 +705,7 @@ var _ = Describe("Server", func() {
705705 Expect(err).ToNot(HaveOccurred())
706706 Expect(resp.StatusCode).To(Equal(http.StatusOK))
707707
708− body, err := ioutil.ReadAll(resp.Body)
708+ body, err := io.ReadAll(resp.Body)
709709 Expect(err).ToNot(HaveOccurred())
710710 Expect(string(body)).To(Equal(hello))
711711 })
@@ -761,7 +761,7 @@ var _ = Describe("Server", func() {
761761 Expect(err).ToNot(HaveOccurred())
762762 Expect(resp.StatusCode).To(Equal(http.StatusOK))
763763
764− body, err := ioutil.ReadAll(resp.Body)
764+ body, err := io.ReadAll(resp.Body)
765765 Expect(err).ToNot(HaveOccurred())
766766 Expect(string(body)).To(Equal(hello))
767767 })
@@ -815,7 +815,7 @@ var _ = Describe("Server", func() {
815815 Expect(err).ToNot(HaveOccurred())
816816 Expect(resp.StatusCode).To(Equal(http.StatusOK))
817817
818− body, err := ioutil.ReadAll(resp.Body)
818+ body, err := io.ReadAll(resp.Body)
819819 Expect(err).ToNot(HaveOccurred())
820820 Expect(string(body)).To(Equal(hello))
821821 })
@@ -886,7 +886,7 @@ var _ = Describe("Server", func() {
886886 Expect(err).ToNot(HaveOccurred())
887887 Expect(resp.StatusCode).To(Equal(http.StatusOK))
888888
889− body, err := ioutil.ReadAll(resp.Body)
889+ body, err := io.ReadAll(resp.Body)
890890 Expect(err).ToNot(HaveOccurred())
891891 Expect(string(body)).To(Equal(hello))
892892 })
@@ -901,7 +901,7 @@ var _ = Describe("Server", func() {
901901 Expect(err).ToNot(HaveOccurred())
902902 Expect(resp.StatusCode).To(Equal(http.StatusOK))
903903
904− body, err := ioutil.ReadAll(resp.Body)
904+ body, err := io.ReadAll(resp.Body)
905905 Expect(err).ToNot(HaveOccurred())
906906 Expect(string(body)).To(Equal(hello))
907907 })
pkg/providers/util/claim_extractor.go+1−1
@@ -98,7 +98,7 @@ func (c *claimExtractor) loadProfileClaims() (*simplejson.Json, error) {
9898 WithContext(c.ctx).
9999 WithHeaders(c.requestHeaders).
100100 Do().
101− UnmarshalJSON()
101+ UnmarshalSimpleJSON()
102102 if err != nil {
103103 return nil, fmt.Errorf("error making request to profile URL: %v", err)
104104 }
pkg/requests/builder.go+1−2
@@ -4,7 +4,6 @@ import (
44 "context"
55 "fmt"
66 "io"
7− "io/ioutil"
87 "net/http"
98)
109
@@ -107,7 +106,7 @@ func (r *builder) do() Result {
107106 }
108107
109108 defer resp.Body.Close()
110− body, err := ioutil.ReadAll(resp.Body)
109+ body, err := io.ReadAll(resp.Body)
111110 if err != nil {
112111 r.result = &result{err: fmt.Errorf("error reading response body: %v", err)}
113112 return r.result
pkg/requests/builder_test.go+3−3
@@ -285,7 +285,7 @@ func assertSuccessfulRequest(builder func() Builder, expectedRequest testHTTPReq
285285
286286 BeforeEach(func() {
287287 var err error
288− response, err = builder().Do().UnmarshalJSON()
288+ response, err = builder().Do().UnmarshalSimpleJSON()
289289 Expect(err).ToNot(HaveOccurred())
290290 })
291291
@@ -340,7 +340,7 @@ func assertRequestError(builder func() Builder, errorMessage string) {
340340
341341 Context("UnmarshalJSON", func() {
342342 It("returns an error", func() {
343− resp, err := builder().Do().UnmarshalJSON()
343+ resp, err := builder().Do().UnmarshalSimpleJSON()
344344 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
345345 Expect(resp).To(BeNil())
346346 })
@@ -368,7 +368,7 @@ func assertJSONError(builder func() Builder, errorMessage string) {
368368
369369 Context("UnmarshalJSON", func() {
370370 It("returns an error", func() {
371− resp, err := builder().Do().UnmarshalJSON()
371+ resp, err := builder().Do().UnmarshalSimpleJSON()
372372 Expect(err).To(MatchError(ContainSubstring(errorMessage)))
373373 Expect(resp).To(BeNil())
374374 })
pkg/requests/requests_suite_test.go+2−2
@@ -3,7 +3,7 @@ package requests
33import (
44 "encoding/json"
55 "fmt"
6− "io/ioutil"
6+ "io"
77 "log"
88 "net/http"
99 "net/http/httptest"
@@ -82,7 +82,7 @@ func toTestHTTPRequest(req *http.Request) (testHTTPRequest, error) {
8282 requestBody := []byte{}
8383 if req.Body != http.NoBody {
8484 var err error
85− requestBody, err = ioutil.ReadAll(req.Body)
85+ requestBody, err = io.ReadAll(req.Body)
8686 if err != nil {
8787 return testHTTPRequest{}, err
8888 }
pkg/requests/result.go+3−3
@@ -15,7 +15,7 @@ type Result interface {
1515 Headers() http.Header
1616 Body() []byte
1717 UnmarshalInto(interface{}) error
18− UnmarshalJSON() (*simplejson.Json, error)
18+ UnmarshalSimpleJSON() (*simplejson.Json, error)
1919}
2020
2121type result struct {
@@ -66,10 +66,10 @@ func (r *result) UnmarshalInto(into interface{}) error {
6666 return nil
6767}
6868
69−// UnmarshalJSON performs the request and attempts to unmarshal the response into a
69+// UnmarshalSimpleJSON performs the request and attempts to unmarshal the response into a
7070// simplejson.Json. The response body is assume to be JSON.
7171// The response must have a 200 status otherwise an error will be returned.
72−func (r *result) UnmarshalJSON() (*simplejson.Json, error) {
72+func (r *result) UnmarshalSimpleJSON() (*simplejson.Json, error) {
7373 body, err := r.getBodyForUnmarshal()
7474 if err != nil {
7575 return nil, err
pkg/requests/result_test.go+1−1
@@ -198,7 +198,7 @@ var _ = Describe("Result suite", func() {
198198
199199 DescribeTable("with a result",
200200 func(in unmarshalJSONTableInput) {
201− j, err := in.result.UnmarshalJSON()
201+ j, err := in.result.UnmarshalSimpleJSON()
202202 if in.expectedErr != nil {
203203 Expect(err).To(MatchError(in.expectedErr))
204204 Expect(j).To(BeNil())
pkg/sessions/redis/redis_store.go+2−2
@@ -5,7 +5,7 @@ import (
55 "crypto/tls"
66 "crypto/x509"
77 "fmt"
8− "io/ioutil"
8+ "os"
99 "time"
1010
1111 "github.com/go-redis/redis/v8"
@@ -170,7 +170,7 @@ func setupTLSConfig(opts options.RedisStoreOptions, opt *redis.Options) error {
170170 if rootCAs == nil {
171171 rootCAs = x509.NewCertPool()
172172 }
173− certs, err := ioutil.ReadFile(opts.CAPath)
173+ certs, err := os.ReadFile(opts.CAPath)
174174 if err != nil {
175175 return fmt.Errorf("failed to load %q, %v", opts.CAPath, err)
176176 }
pkg/upstream/upstream_suite_test.go+6−6
@@ -3,7 +3,7 @@ package upstream
33import (
44 "encoding/json"
55 "fmt"
6− "io/ioutil"
6+ "io"
77 "log"
88 "net/http"
99 "net/http/httptest"
@@ -35,12 +35,12 @@ func TestUpstreamSuite(t *testing.T) {
3535
3636var _ = BeforeSuite(func() {
3737 // Set up files for serving via file servers
38− dir, err := ioutil.TempDir("", "oauth2-proxy-upstream-suite")
38+ dir, err := os.MkdirTemp("", "oauth2-proxy-upstream-suite")
3939 Expect(err).ToNot(HaveOccurred())
40− Expect(ioutil.WriteFile(path.Join(dir, "foo"), []byte("foo"), 0644)).To(Succeed())
41− Expect(ioutil.WriteFile(path.Join(dir, "bar"), []byte("bar"), 0644)).To(Succeed())
40+ Expect(os.WriteFile(path.Join(dir, "foo"), []byte("foo"), 0644)).To(Succeed())
41+ Expect(os.WriteFile(path.Join(dir, "bar"), []byte("bar"), 0644)).To(Succeed())
4242 Expect(os.Mkdir(path.Join(dir, "subdir"), os.ModePerm)).To(Succeed())
43− Expect(ioutil.WriteFile(path.Join(dir, "subdir", "baz"), []byte("baz"), 0644)).To(Succeed())
43+ Expect(os.WriteFile(path.Join(dir, "subdir", "baz"), []byte("baz"), 0644)).To(Succeed())
4444 filesDir = dir
4545
4646 // Set up a webserver that reflects requests
@@ -148,7 +148,7 @@ func toTestHTTPRequest(req *http.Request) (testHTTPRequest, error) {
148148 requestBody := []byte{}
149149 if req.Body != http.NoBody {
150150 var err error
151− requestBody, err = ioutil.ReadAll(req.Body)
151+ requestBody, err = io.ReadAll(req.Body)
152152 if err != nil {
153153 return testHTTPRequest{}, err
154154 }
pkg/util/util.go+2−2
@@ -6,10 +6,10 @@ import (
66 "crypto/x509"
77 "crypto/x509/pkix"
88 "fmt"
9− "io/ioutil"
109 "math/big"
1110 "net"
1211 "net/url"
12+ "os"
1313 "strings"
1414 "time"
1515)
@@ -21,7 +21,7 @@ func GetCertPool(paths []string) (*x509.CertPool, error) {
2121 pool := x509.NewCertPool()
2222 for _, path := range paths {
2323 // Cert paths are a configurable option
24− data, err := ioutil.ReadFile(path) // #nosec G304
24+ data, err := os.ReadFile(path) // #nosec G304
2525 if err != nil {
2626 return nil, fmt.Errorf("certificate authority file (%s) could not be read - %s", path, err)
2727 }
pkg/util/util_test.go+2−3
@@ -3,7 +3,6 @@ package util
33import (
44 "crypto/x509"
55 "encoding/pem"
6− "io/ioutil"
76 "os"
87 "testing"
98
@@ -183,7 +182,7 @@ WrW4JMzLaGDtoHxRNNfo8E7fGkQ=
183182)
184183
185184func makeTestCertFile(t *testing.T, pem, dir string) *os.File {
186− file, err := ioutil.TempFile(dir, "test-certfile")
185+ file, err := os.CreateTemp(dir, "test-certfile")
187186 assert.NoError(t, err)
188187 _, err = file.Write([]byte(pem))
189188 assert.NoError(t, err)
@@ -196,7 +195,7 @@ func TestGetCertPool_NoRoots(t *testing.T) {
196195}
197196
198197func TestGetCertPool(t *testing.T) {
199− tempDir, err := ioutil.TempDir("", "certtest")
198+ tempDir, err := os.MkdirTemp("", "certtest")
200199 assert.NoError(t, err)
201200 defer func(path string) {
202201 rerr := os.RemoveAll(path)
pkg/validation/common_test.go+1−2
@@ -1,7 +1,6 @@
11package validation
22
33import (
4− "io/ioutil"
54 "os"
65
76 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -18,7 +17,7 @@ var _ = Describe("Common", func() {
1817 BeforeEach(func() {
1918 validSecretSourceValue = []byte("This is a secret source value")
2019 Expect(os.Setenv(validSecretSourceEnv, "This is a secret source env")).To(Succeed())
21− tmp, err := ioutil.TempFile("", "oauth2-proxy-secret-source-test")
20+ tmp, err := os.CreateTemp("", "oauth2-proxy-secret-source-test")
2221 Expect(err).ToNot(HaveOccurred())
2322 defer tmp.Close()
2423
pkg/validation/options_test.go+1−2
@@ -2,7 +2,6 @@ package validation
22
33import (
44 "crypto"
5− "io/ioutil"
65 "net/url"
76 "os"
87 "strings"
@@ -205,7 +204,7 @@ func TestRealClientIPHeader(t *testing.T) {
205204}
206205
207206func TestProviderCAFilesError(t *testing.T) {
208− file, err := ioutil.TempFile("", "absent.*.crt")
207+ file, err := os.CreateTemp("", "absent.*.crt")
209208 assert.NoError(t, err)
210209 assert.NoError(t, file.Close())
211210 assert.NoError(t, os.Remove(file.Name()))
pkg/validation/providers.go+1−2
@@ -2,7 +2,6 @@ package validation
22
33import (
44 "fmt"
5− "io/ioutil"
65 "os"
76
87 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
@@ -53,7 +52,7 @@ func validateProvider(provider options.Provider, providerIDs map[string]struct{}
5352 msgs = append(msgs, "missing setting: client-secret or client-secret-file")
5453 }
5554 if provider.ClientSecret == "" && provider.ClientSecretFile != "" {
56− _, err := ioutil.ReadFile(provider.ClientSecretFile)
55+ _, err := os.ReadFile(provider.ClientSecretFile)
5756 if err != nil {
5857 msgs = append(msgs, "could not read client secret file: "+provider.ClientSecretFile)
5958 }
pkg/watcher/watcher.go+2−2
@@ -44,8 +44,8 @@ func WatchFileForUpdates(filename string, done <-chan bool, action func()) error
4444
4545// Filter file operations based on the events sent by the watcher.
4646// Execute the action() function when the following conditions are met:
47−// - the real path of the file was changed (Kubernetes ConfigMap/Secret)
48−// - the file is modified or created
47+// - the real path of the file was changed (Kubernetes ConfigMap/Secret)
48+// - the file is modified or created
4949func filterEvent(watcher *fsnotify.Watcher, event fsnotify.Event, filename string, action func()) {
5050 switch filepath.Clean(event.Name) == filename {
5151 // In Kubernetes the file path is a symlink, so we should take action
providers/azure.go+1−1
@@ -347,7 +347,7 @@ func (p *AzureProvider) getEmailFromProfileAPI(ctx context.Context, accessToken
347347 WithContext(ctx).
348348 WithHeaders(makeAzureHeader(accessToken)).
349349 Do().
350− UnmarshalJSON()
350+ UnmarshalSimpleJSON()
351351 if err != nil {
352352 return "", err
353353 }
providers/digitalocean.go+1−1
@@ -72,7 +72,7 @@ func (p *DigitalOceanProvider) GetEmailAddress(ctx context.Context, s *sessions.
7272 WithContext(ctx).
7373 WithHeaders(makeOIDCHeader(s.AccessToken)).
7474 Do().
75− UnmarshalJSON()
75+ UnmarshalSimpleJSON()
7676 if err != nil {
7777 return "", err
7878 }
providers/google.go+1−2
@@ -8,7 +8,6 @@ import (
88 "errors"
99 "fmt"
1010 "io"
11− "io/ioutil"
1211 "net/url"
1312 "os"
1413 "strings"
@@ -231,7 +230,7 @@ func (p *GoogleProvider) setGroupRestriction(groups []string, adminEmail string,
231230}
232231
233232func getAdminService(adminEmail string, credentialsReader io.Reader) *admin.Service {
234− data, err := ioutil.ReadAll(credentialsReader)
233+ data, err := io.ReadAll(credentialsReader)
235234 if err != nil {
236235 logger.Fatal("can't read Google credentials file:", err)
237236 }
providers/google_test.go−1
@@ -166,7 +166,6 @@ func TestGoogleProviderGroupValidator(t *testing.T) {
166166 }
167167}
168168
169−//
170169func TestGoogleProviderGetEmailAddressInvalidEncoding(t *testing.T) {
171170 p := newGoogleProvider(t)
172171 body, err := json.Marshal(redeemResponse{
providers/keycloak.go+1−1
@@ -77,7 +77,7 @@ func (p *KeycloakProvider) EnrichSession(ctx context.Context, s *sessions.Sessio
7777 WithContext(ctx).
7878 SetHeader("Authorization", "Bearer "+s.AccessToken).
7979 Do().
80− UnmarshalJSON()
80+ UnmarshalSimpleJSON()
8181 if err != nil {
8282 logger.Errorf("failed making request %v", err)
8383 return err
providers/keycloak_oidc.go+15−14
@@ -124,20 +124,21 @@ func (p *KeycloakOIDCProvider) getAccessClaims(ctx context.Context, s *sessions.
124124// the format `client:role`.
125125//
126126// ResourceAccess format:
127−// "resource_access": {
128−// "clientA": {
129−// "roles": [
130−// "roleA"
131−// ]
132−// },
133−// "clientB": {
134−// "roles": [
135−// "roleA",
136−// "roleB",
137−// "roleC"
138−// ]
139−// }
140−// }
127+//
128+// "resource_access": {
129+// "clientA": {
130+// "roles": [
131+// "roleA"
132+// ]
133+// },
134+// "clientB": {
135+// "roles": [
136+// "roleA",
137+// "roleB",
138+// "roleC"
139+// ]
140+// }
141+// }
141142func getClientRoles(claims *accessClaims) []string {
142143 var clientRoles []string
143144 for clientName, access := range claims.ResourceAccess {
providers/linkedin.go+1−1
@@ -90,7 +90,7 @@ func (p *LinkedInProvider) GetEmailAddress(ctx context.Context, s *sessions.Sess
9090 WithContext(ctx).
9191 WithHeaders(makeLinkedInHeader(s.AccessToken)).
9292 Do().
93− UnmarshalJSON()
93+ UnmarshalSimpleJSON()
9494 if err != nil {
9595 return "", err
9696 }
providers/logingov.go+2−2
@@ -7,9 +7,9 @@ import (
77 "crypto/rsa"
88 "errors"
99 "fmt"
10− "io/ioutil"
1110 "math/big"
1211 "net/url"
12+ "os"
1313 "time"
1414
1515 "github.com/golang-jwt/jwt"
@@ -123,7 +123,7 @@ func (p *LoginGovProvider) configure(opts options.LoginGovOptions) error {
123123 p.JWTKey = signKey
124124 case opts.JWTKeyFile != "":
125125 // The JWT key is in the filesystem
126− keyData, err := ioutil.ReadFile(opts.JWTKeyFile)
126+ keyData, err := os.ReadFile(opts.JWTKeyFile)
127127 if err != nil {
128128 return fmt.Errorf("could not read key file: %v", opts.JWTKeyFile)
129129 }
providers/nextcloud.go+1−1
@@ -44,7 +44,7 @@ func (p *NextcloudProvider) EnrichSession(ctx context.Context, s *sessions.Sessi
4444 WithContext(ctx).
4545 SetHeader("Authorization", "Bearer "+s.AccessToken).
4646 Do().
47− UnmarshalJSON()
47+ UnmarshalSimpleJSON()
4848 if err != nil {
4949 logger.Errorf("failed making request %v", err)
5050 return err
providers/provider_data.go+2−2
@@ -4,9 +4,9 @@ import (
44 "context"
55 "errors"
66 "fmt"
7− "io/ioutil"
87 "net/http"
98 "net/url"
9+ "os"
1010 "regexp"
1111 "strings"
1212
@@ -67,7 +67,7 @@ func (p *ProviderData) GetClientSecret() (clientSecret string, err error) {
6767 }
6868
6969 // Getting ClientSecret can fail in runtime so we need to report it without returning the file name to the user
70− fileClientSecret, err := ioutil.ReadFile(p.ClientSecretFile)
70+ fileClientSecret, err := os.ReadFile(p.ClientSecretFile)
7171 if err != nil {
7272 logger.Errorf("error reading client secret file %s: %s", p.ClientSecretFile, err)
7373 return "", errors.New("could not read client secret file")
providers/providers_test.go+1−2
@@ -1,7 +1,6 @@
11package providers
22
33import (
4− "io/ioutil"
54 "os"
65 "testing"
76
@@ -43,7 +42,7 @@ func TestClientSecretFileOptionFails(t *testing.T) {
4342func TestClientSecretFileOption(t *testing.T) {
4443 g := NewWithT(t)
4544
46− f, err := ioutil.TempFile("", "client_secret_temp_file_")
45+ f, err := os.CreateTemp("", "client_secret_temp_file_")
4746 g.Expect(err).ToNot(HaveOccurred())
4847
4948 clientSecretFileName := f.Name()
validator_test.go+1−2
@@ -1,7 +1,6 @@
11package main
22
33import (
4− "io/ioutil"
54 "os"
65 "strings"
76 "testing"
@@ -18,7 +17,7 @@ type ValidatorTest struct {
1817func NewValidatorTest(t *testing.T) *ValidatorTest {
1918 vt := &ValidatorTest{}
2019 var err error
21− f, err := ioutil.TempFile("", "test_auth_emails_")
20+ f, err := os.CreateTemp("", "test_auth_emails_")
2221 if err != nil {
2322 t.Fatalf("failed to create temp file: %v", err)
2423 }