Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: modernize code #378

Merged
merged 18 commits into from
Dec 22, 2024
Prev Previous commit
Next Next commit
chore: modernize code
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
  • Loading branch information
jkroepke committed Dec 21, 2024
commit 4c69e31dcb29ca48a92c6ad4a865820cd192eeaf
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ linters-settings:
revive:
rules:
- name: argument-limit
arguments: [ 6 ]
arguments: [ 7 ]
- name: atomic
- name: bare-return
- name: blank-imports
Expand Down
2 changes: 0 additions & 2 deletions cmd/daemon/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)

// Execute runs the main program logic of openvpn-auth-oauth2.
func Execute(args []string, logWriter io.Writer, version, commit, date string) int {

Check failure on line 31 in cmd/daemon/root.go

View workflow job for this annotation

GitHub Actions / lint

calculated cyclomatic complexity for function Execute is 22, max is 10 (cyclop)
conf, err := configure(args, logWriter, version, commit, date)
if err != nil {
if errors.Is(err, flag.ErrHelp) {
Expand Down Expand Up @@ -64,8 +64,6 @@
provider, err = google.NewProvider(ctx, conf, httpClient)
default:
err = errors.New("unknown oauth2 provider: " + conf.OAuth2.Provider)

return 1
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/oauth2/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
id = session.Client.SessionID
}

c.authorizeParams = append(c.authorizeParams, rp.WithURLParam("nonce", c.getNonce(id)))

Check failure on line 84 in internal/oauth2/handler.go

View workflow job for this annotation

GitHub Actions / lint

modifies-value-receiver: suspicious assignment to a by-value method receiver (revive)
}

rp.AuthURLHandler(func() string {
Expand Down Expand Up @@ -192,7 +192,7 @@

if !c.conf.OAuth2.Refresh.ValidateUser {
if err := c.storage.Set(clientID, types.EmptyToken); err != nil {
logger.Warn(err.Error())
logger.LogAttrs(ctx, slog.LevelWarn, err.Error())
}

return
Expand Down
2 changes: 2 additions & 0 deletions internal/oauth2/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func TestNewProvider(t *testing.T) {
t.Fatal("unknown oauth2 provider: " + tt.conf.OAuth2.Provider)
}

require.Error(t, err)

oAuth2Client, err := oauth2.New(ctx, logger.Logger, tt.conf, http.DefaultClient, testutils.NewFakeStorage(), provider, testutils.NewFakeOpenVPNClient())
if tt.err != "" {
require.Error(t, err)
Expand Down
Loading