Skip to content

Commit

Permalink
fix: append string bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyu committed Sep 5, 2024
1 parent b1d353a commit 25d3c1e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/authorization/ts_app_authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,8 @@ func (t *TsAuthorizer) getOIDCClients() error {
continue
}

newHostToken := append(hostToken[:1], "local")
var newHostToken []string
newHostToken = append(newHostToken, hostToken[0], "local")
newHostToken = append(newHostToken, hostToken[1:]...)

url.Host = strings.Join(newHostToken, ".")
Expand Down
27 changes: 27 additions & 0 deletions internal/authorization/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import (
"encoding/json"
"fmt"
"net"
"net/url"
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/klog/v2"

"github.com/authelia/authelia/v4/internal/authentication"
"github.com/authelia/authelia/v4/internal/authorization/application"
Expand Down Expand Up @@ -235,3 +238,27 @@ func TestPolicy(t *testing.T) {

fmt.Printf("%v", policies)
}

func TestAddLocal(t *testing.T) {
redirect_uri := "https://222fd105.xuejingjie8.myterminus.com/auth/login"
url, err := url.Parse(redirect_uri)
if err != nil {
klog.Errorf("%s oidc client redirect uri invalid, %s, %v", "test", redirect_uri, err)
return
}
hostToken := strings.Split(url.Host, ".")
if len(hostToken) < 2 {
klog.Errorf("%s oidc client redirect uri host invalid, %s", "test", redirect_uri)
return
}

var newHostToken []string
newHostToken = append(newHostToken, hostToken[0], "local")
newHostToken = append(newHostToken, hostToken[1:]...)

url.Host = strings.Join(newHostToken, ".")
local_redirect_uri := url.String()

t.Log(local_redirect_uri)

}

0 comments on commit 25d3c1e

Please sign in to comment.