Skip to content

Commit

Permalink
feat(auth): DSP-417 - refactor with upstream changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-r33d committed Feb 4, 2025
1 parent 78cb5aa commit 7f018a9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
"log/slog"
"net/url"
"os"
"time"
Expand Down Expand Up @@ -123,10 +122,10 @@ func getPlatformConfiguration(endpoint, publicClientID string, tlsNoVerify bool)
}
}

c.authCodeFlowPort, e = s.PlatformConfiguration.CodeFlowPort()
c.authCodeFlowPort, e = s.PlatformConfiguration.PublicClientLocalPort()

Check failure on line 125 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

s.PlatformConfiguration.PublicClientLocalPort undefined (type sdk.PlatformConfiguration has no field or method PublicClientLocalPort)

Check failure on line 125 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

s.PlatformConfiguration.PublicClientLocalPort undefined (type sdk.PlatformConfiguration has no field or method PublicClientLocalPort)

Check failure on line 125 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

s.PlatformConfiguration.PublicClientLocalPort undefined (type sdk.PlatformConfiguration has no field or method PublicClientLocalPort)

Check failure on line 125 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

s.PlatformConfiguration.PublicClientLocalPort undefined (type sdk.PlatformConfiguration has no field or method PublicClientLocalPort)

Check failure on line 125 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / unit tests

s.PlatformConfiguration.PublicClientLocalPort undefined (type sdk.PlatformConfiguration has no field or method PublicClientLocalPort)

if e != nil {
err = errors.Join(err, sdk.ErrPlatformCodeFlowPort)
err = errors.Join(err, sdk.ErrPlatformPublicClientLocalPortNotFound)

Check failure on line 128 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound

Check failure on line 128 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound

Check failure on line 128 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound

Check failure on line 128 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound

Check failure on line 128 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / unit tests

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound
}

if err != nil {
Expand Down Expand Up @@ -276,11 +275,9 @@ func Login(ctx context.Context, platformEndpoint, tokenURL, authURL, publicClien
func LoginWithPKCE(ctx context.Context, host, publicClientID string, tlsNoVerify bool) (*oauth2.Token, string, error) {
pc, err := getPlatformConfiguration(host, publicClientID, tlsNoVerify)
if err != nil {
if !errors.Is(err, sdk.ErrPlatformCodeFlowPort) {
if !errors.Is(err, sdk.ErrPlatformPublicClientLocalPortNotFound) {

Check failure on line 278 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound (typecheck)

Check failure on line 278 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound) (typecheck)

Check failure on line 278 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / Run govulncheck

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound

Check failure on line 278 in pkg/auth/auth.go

View workflow job for this annotation

GitHub Actions / unit tests

undefined: sdk.ErrPlatformPublicClientLocalPortNotFound
return nil, "", fmt.Errorf("failed to get platform configuration: %w", err)
}
// Fallback to default port.
slog.Warn(fmt.Sprintf("No port specified for code flow, falling back to: %s", defaultAuthCodeFlowPort))
pc.authCodeFlowPort = defaultAuthCodeFlowPort
}

Expand Down

0 comments on commit 7f018a9

Please sign in to comment.