2022-03-29 09:53:19 +00:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
2024-01-17 10:16:48 +00:00
|
|
|
"time"
|
2022-03-29 09:53:19 +00:00
|
|
|
|
2022-04-25 09:16:36 +00:00
|
|
|
"golang.org/x/text/language"
|
2022-03-29 09:53:19 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
http_util "github.com/zitadel/zitadel/internal/api/http"
|
2024-02-28 08:55:54 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/feature"
|
2024-08-12 20:32:01 +00:00
|
|
|
object_v3 "github.com/zitadel/zitadel/pkg/grpc/object/v3alpha"
|
2022-03-29 09:53:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_setInstance(t *testing.T) {
|
|
|
|
type args struct {
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
ctx context.Context
|
|
|
|
req interface{}
|
|
|
|
info *grpc.UnaryServerInfo
|
|
|
|
handler grpc.UnaryHandler
|
|
|
|
verifier authz.InstanceVerifier
|
2022-03-29 09:53:19 +00:00
|
|
|
}
|
|
|
|
type res struct {
|
|
|
|
want interface{}
|
|
|
|
err bool
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
res res
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
"hostname not found, error",
|
|
|
|
args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"invalid host, error",
|
|
|
|
args{
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
ctx: http_util.WithDomainContext(context.Background(), &http_util.DomainCtx{InstanceHost: "host2"}),
|
|
|
|
req: &mockRequest{},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "host"},
|
2022-03-29 09:53:19 +00:00
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"valid host",
|
|
|
|
args{
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
ctx: http_util.WithDomainContext(context.Background(), &http_util.DomainCtx{InstanceHost: "host"}),
|
|
|
|
req: &mockRequest{},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "host"},
|
2022-03-29 09:53:19 +00:00
|
|
|
handler: func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
|
|
return req, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: &mockRequest{},
|
|
|
|
err: false,
|
|
|
|
},
|
|
|
|
},
|
2024-08-12 20:32:01 +00:00
|
|
|
{
|
|
|
|
"explicit instance unset, hostname not found, error",
|
|
|
|
args{
|
|
|
|
ctx: http_util.WithDomainContext(context.Background(), &http_util.DomainCtx{InstanceHost: "host2"}),
|
|
|
|
req: &mockRequestWithExplicitInstance{},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "host"},
|
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"explicit instance unset, invalid host, error",
|
|
|
|
args{
|
|
|
|
ctx: http_util.WithDomainContext(context.Background(), &http_util.DomainCtx{InstanceHost: "host2"}),
|
|
|
|
req: &mockRequestWithExplicitInstance{},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "host"},
|
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"explicit instance unset, valid host",
|
|
|
|
args{
|
|
|
|
ctx: http_util.WithDomainContext(context.Background(), &http_util.DomainCtx{InstanceHost: "host"}),
|
|
|
|
req: &mockRequestWithExplicitInstance{},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "host"},
|
|
|
|
handler: func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
|
|
return req, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
res{
|
|
|
|
want: &mockRequestWithExplicitInstance{},
|
|
|
|
err: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "explicit instance set, id not found, error",
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
req: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Id{
|
|
|
|
Id: "not existing instance id",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
verifier: &mockInstanceVerifier{id: "existing instance id"},
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "explicit instance set, id found, ok",
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
req: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Id{
|
|
|
|
Id: "existing instance id",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
verifier: &mockInstanceVerifier{id: "existing instance id"},
|
|
|
|
handler: func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
|
|
return req, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Id{
|
|
|
|
Id: "existing instance id",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
err: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "explicit instance set, domain not found, error",
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
req: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Domain{
|
|
|
|
Domain: "not existing instance domain",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "existing instance domain"},
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: nil,
|
|
|
|
err: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "explicit instance set, domain found, ok",
|
|
|
|
args: args{
|
|
|
|
ctx: context.Background(),
|
|
|
|
req: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Domain{
|
|
|
|
Domain: "existing instance domain",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
verifier: &mockInstanceVerifier{instanceHost: "existing instance domain"},
|
|
|
|
handler: func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
|
|
return req, nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
res: res{
|
|
|
|
want: &mockRequestWithExplicitInstance{
|
|
|
|
instance: object_v3.Instance{
|
|
|
|
Property: &object_v3.Instance_Domain{
|
|
|
|
Domain: "existing instance domain",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
err: false,
|
|
|
|
},
|
|
|
|
},
|
2022-03-29 09:53:19 +00:00
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
got, err := setInstance(tt.args.ctx, tt.args.req, tt.args.info, tt.args.handler, tt.args.verifier, "", nil)
|
2022-03-29 09:53:19 +00:00
|
|
|
if (err != nil) != tt.res.err {
|
|
|
|
t.Errorf("setInstance() error = %v, wantErr %v", err, tt.res.err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(got, tt.res.want) {
|
|
|
|
t.Errorf("setInstance() got = %v, want %v", got, tt.res.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type mockRequest struct{}
|
|
|
|
|
2024-08-12 20:32:01 +00:00
|
|
|
type mockRequestWithExplicitInstance struct {
|
|
|
|
instance object_v3.Instance
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockRequestWithExplicitInstance) GetInstance() *object_v3.Instance {
|
|
|
|
return &m.instance
|
|
|
|
}
|
|
|
|
|
2022-03-29 09:53:19 +00:00
|
|
|
type mockInstanceVerifier struct {
|
2024-08-12 20:32:01 +00:00
|
|
|
id string
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
instanceHost string
|
|
|
|
publicHost string
|
2022-03-29 09:53:19 +00:00
|
|
|
}
|
|
|
|
|
feat: trusted (instance) domains (#8369)
# Which Problems Are Solved
ZITADEL currently selects the instance context based on a HTTP header
(see https://github.com/zitadel/zitadel/issues/8279#issue-2399959845 and
checks it against the list of instance domains. Let's call it instance
or API domain.
For any context based URL (e.g. OAuth, OIDC, SAML endpoints, links in
emails, ...) the requested domain (instance domain) will be used. Let's
call it the public domain.
In cases of proxied setups, all exposed domains (public domains) require
the domain to be managed as instance domain.
This can either be done using the "ExternalDomain" in the runtime config
or via system API, which requires a validation through CustomerPortal on
zitadel.cloud.
# How the Problems Are Solved
- Two new headers / header list are added:
- `InstanceHostHeaders`: an ordered list (first sent wins), which will
be used to match the instance.
(For backward compatibility: the `HTTP1HostHeader`, `HTTP2HostHeader`
and `forwarded`, `x-forwarded-for`, `x-forwarded-host` are checked
afterwards as well)
- `PublicHostHeaders`: an ordered list (first sent wins), which will be
used as public host / domain. This will be checked against a list of
trusted domains on the instance.
- The middleware intercepts all requests to the API and passes a
`DomainCtx` object with the hosts and protocol into the context
(previously only a computed `origin` was passed)
- HTTP / GRPC server do not longer try to match the headers to instances
themself, but use the passed `http.DomainContext` in their interceptors.
- The `RequestedHost` and `RequestedDomain` from authz.Instance are
removed in favor of the `http.DomainContext`
- When authenticating to or signing out from Console UI, the current
`http.DomainContext(ctx).Origin` (already checked by instance
interceptor for validity) is used to compute and dynamically add a
`redirect_uri` and `post_logout_redirect_uri`.
- Gateway passes all configured host headers (previously only did
`x-zitadel-*`)
- Admin API allows to manage trusted domain
# Additional Changes
None
# Additional Context
- part of #8279
- open topics:
- "single-instance" mode
- Console UI
2024-07-31 15:00:38 +00:00
|
|
|
func (m *mockInstanceVerifier) InstanceByHost(_ context.Context, instanceHost, publicHost string) (authz.Instance, error) {
|
|
|
|
if instanceHost != m.instanceHost {
|
|
|
|
return nil, fmt.Errorf("invalid host")
|
|
|
|
}
|
|
|
|
if publicHost == "" {
|
|
|
|
return &mockInstance{}, nil
|
|
|
|
}
|
|
|
|
if publicHost != instanceHost && publicHost != m.publicHost {
|
2022-03-29 09:53:19 +00:00
|
|
|
return nil, fmt.Errorf("invalid host")
|
|
|
|
}
|
|
|
|
return &mockInstance{}, nil
|
|
|
|
}
|
|
|
|
|
2024-08-12 20:32:01 +00:00
|
|
|
func (m *mockInstanceVerifier) InstanceByID(_ context.Context, id string) (authz.Instance, error) {
|
|
|
|
if id != m.id {
|
|
|
|
return nil, fmt.Errorf("not found")
|
|
|
|
}
|
|
|
|
return &mockInstance{}, nil
|
|
|
|
}
|
2023-02-15 01:52:11 +00:00
|
|
|
|
2022-03-29 09:53:19 +00:00
|
|
|
type mockInstance struct{}
|
|
|
|
|
2024-01-17 10:16:48 +00:00
|
|
|
func (m *mockInstance) Block() *bool {
|
|
|
|
panic("shouldn't be called here")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockInstance) AuditLogRetention() *time.Duration {
|
|
|
|
panic("shouldn't be called here")
|
|
|
|
}
|
|
|
|
|
2022-03-29 09:53:19 +00:00
|
|
|
func (m *mockInstance) InstanceID() string {
|
|
|
|
return "instanceID"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockInstance) ProjectID() string {
|
|
|
|
return "projectID"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mockInstance) ConsoleClientID() string {
|
|
|
|
return "consoleClientID"
|
|
|
|
}
|
2022-04-12 14:20:17 +00:00
|
|
|
|
2022-04-14 12:19:18 +00:00
|
|
|
func (m *mockInstance) ConsoleApplicationID() string {
|
|
|
|
return "consoleApplicationID"
|
|
|
|
}
|
|
|
|
|
2022-04-25 09:16:36 +00:00
|
|
|
func (m *mockInstance) DefaultLanguage() language.Tag {
|
|
|
|
return language.English
|
|
|
|
}
|
|
|
|
|
2022-06-03 12:30:39 +00:00
|
|
|
func (m *mockInstance) DefaultOrganisationID() string {
|
|
|
|
return "orgID"
|
|
|
|
}
|
|
|
|
|
2022-12-14 06:17:36 +00:00
|
|
|
func (m *mockInstance) SecurityPolicyAllowedOrigins() []string {
|
|
|
|
return nil
|
|
|
|
}
|
2024-02-28 08:55:54 +00:00
|
|
|
|
2024-02-28 10:21:11 +00:00
|
|
|
func (m *mockInstance) EnableImpersonation() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-28 08:55:54 +00:00
|
|
|
func (m *mockInstance) Features() feature.Features {
|
|
|
|
return feature.Features{}
|
|
|
|
}
|