Skip to content

Commit

Permalink
fix: login url configurable (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
stebenz authored Dec 19, 2024
1 parent e0de468 commit 1bbf277
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/provider/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestSSO_verifyPostSignature(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
spConfig := &serviceprovider.Config{Metadata: []byte(tt.args.spMetadata)}

sp, err := serviceprovider.NewServiceProvider("test", spConfig, "")
sp, err := serviceprovider.NewServiceProvider("test", spConfig, func(s string) string { return "" })
if err != nil {
t.Errorf("verifyPostSignature() got = %v, wanted to create service provider instance", err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/redirect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestRedirect_verifyRedirectSignature(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
spConfig := &serviceprovider.Config{Metadata: []byte(tt.args.spMetadata)}

sp, err := serviceprovider.NewServiceProvider("test", spConfig, "")
sp, err := serviceprovider.NewServiceProvider("test", spConfig, func(s string) string { return "" })
if err != nil {
t.Errorf("verifyRedirectSignature() got = %v, wanted to create service provider instance", err)
return
Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/serviceprovider/serviceprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ type ServiceProvider struct {
ID string
Metadata *md.EntityDescriptorType
signerPublicKey interface{}
defaultLoginURL string
loginURL func(string) string
}

func (sp *ServiceProvider) GetEntityID() string {
return string(sp.Metadata.EntityID)
}

func (sp *ServiceProvider) LoginURL(id string) string {
return sp.defaultLoginURL + id
return sp.loginURL(id)
}

func NewServiceProvider(id string, config *Config, defaultLoginURL string) (*ServiceProvider, error) {
func NewServiceProvider(id string, config *Config, loginURL func(string) string) (*ServiceProvider, error) {
metadata, err := xml.ParseMetadataXmlIntoStruct(config.Metadata)
if err != nil {
return nil, err
Expand All @@ -54,7 +54,7 @@ func NewServiceProvider(id string, config *Config, defaultLoginURL string) (*Ser
ID: id,
Metadata: metadata,
signerPublicKey: signerPublicKey,
defaultLoginURL: defaultLoginURL,
loginURL: loginURL,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/sso_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func TestSSO_ssoHandleFunc(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
endpoint := NewEndpoint(tt.args.metadataEndpoint)
spInst, err := serviceprovider.NewServiceProvider(tt.args.sp.entityID, &serviceprovider.Config{Metadata: []byte(tt.args.sp.metadata)}, "")
spInst, err := serviceprovider.NewServiceProvider(tt.args.sp.entityID, &serviceprovider.Config{Metadata: []byte(tt.args.sp.metadata)}, func(s string) string { return "" })
if err != nil {
t.Errorf("error while creating service provider")
return
Expand Down

0 comments on commit 1bbf277

Please sign in to comment.