mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 16:26:38 +00:00
add AuthCallbackURL
This commit is contained in:
@@ -213,11 +213,14 @@ func applyEmbeddedIdPConfig(ctx context.Context, cfg *nbconfig.Config) error {
|
|||||||
// Set HttpConfig values from EmbeddedIdP
|
// Set HttpConfig values from EmbeddedIdP
|
||||||
cfg.HttpConfig.AuthIssuer = issuer
|
cfg.HttpConfig.AuthIssuer = issuer
|
||||||
cfg.HttpConfig.AuthAudience = "netbird-dashboard"
|
cfg.HttpConfig.AuthAudience = "netbird-dashboard"
|
||||||
|
cfg.HttpConfig.AuthClientID = cfg.HttpConfig.AuthAudience
|
||||||
cfg.HttpConfig.CLIAuthAudience = "netbird-cli"
|
cfg.HttpConfig.CLIAuthAudience = "netbird-cli"
|
||||||
cfg.HttpConfig.AuthUserIDClaim = "sub"
|
cfg.HttpConfig.AuthUserIDClaim = "sub"
|
||||||
cfg.HttpConfig.AuthKeysLocation = issuer + "/keys"
|
cfg.HttpConfig.AuthKeysLocation = issuer + "/keys"
|
||||||
cfg.HttpConfig.OIDCConfigEndpoint = issuer + "/.well-known/openid-configuration"
|
cfg.HttpConfig.OIDCConfigEndpoint = issuer + "/.well-known/openid-configuration"
|
||||||
cfg.HttpConfig.IdpSignKeyRefreshEnabled = true
|
cfg.HttpConfig.IdpSignKeyRefreshEnabled = true
|
||||||
|
callbackURL := strings.TrimSuffix(cfg.HttpConfig.AuthIssuer, "/oauth2")
|
||||||
|
cfg.HttpConfig.AuthCallbackURL = callbackURL + "/api/oauth/callback"
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware/v2"
|
grpcMiddleware "github.com/grpc-ecosystem/go-grpc-middleware/v2"
|
||||||
@@ -174,19 +173,12 @@ func (s *BaseServer) ReverseProxyGRPCServer() *nbgrpc.ProxyServiceServer {
|
|||||||
|
|
||||||
func (s *BaseServer) proxyOIDCConfig() nbgrpc.ProxyOIDCConfig {
|
func (s *BaseServer) proxyOIDCConfig() nbgrpc.ProxyOIDCConfig {
|
||||||
return Create(s, func() nbgrpc.ProxyOIDCConfig {
|
return Create(s, func() nbgrpc.ProxyOIDCConfig {
|
||||||
// TODO: this is weird, double check
|
|
||||||
// Build callback URL - this should be the management server's callback endpoint
|
|
||||||
// For embedded IdP, derive from issuer. For external, use a configured value or derive from issuer.
|
|
||||||
// The callback URL should be registered in the IdP's allowed redirect URIs for the dashboard client.
|
|
||||||
callbackURL := strings.TrimSuffix(s.Config.HttpConfig.AuthIssuer, "/oauth2")
|
|
||||||
callbackURL = callbackURL + "/api/oauth/callback"
|
|
||||||
|
|
||||||
return nbgrpc.ProxyOIDCConfig{
|
return nbgrpc.ProxyOIDCConfig{
|
||||||
Issuer: s.Config.HttpConfig.AuthIssuer,
|
Issuer: s.Config.HttpConfig.AuthIssuer,
|
||||||
// todo: double check auth clientID value
|
// todo: double check auth clientID value
|
||||||
ClientID: s.Config.HttpConfig.AuthClientID, // Reuse dashboard client
|
ClientID: s.Config.HttpConfig.AuthClientID, // Reuse dashboard client
|
||||||
Scopes: []string{"openid", "profile", "email"},
|
Scopes: []string{"openid", "profile", "email"},
|
||||||
CallbackURL: callbackURL,
|
CallbackURL: s.Config.HttpConfig.AuthCallbackURL,
|
||||||
HMACKey: []byte(s.Config.DataStoreEncryptionKey), // Use the datastore encryption key for OIDC state HMACs, this should ensure all management instances are using the same key.
|
HMACKey: []byte(s.Config.DataStoreEncryptionKey), // Use the datastore encryption key for OIDC state HMACs, this should ensure all management instances are using the same key.
|
||||||
Audience: s.Config.HttpConfig.AuthAudience,
|
Audience: s.Config.HttpConfig.AuthAudience,
|
||||||
KeysLocation: s.Config.HttpConfig.AuthKeysLocation,
|
KeysLocation: s.Config.HttpConfig.AuthKeysLocation,
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ type HttpServerConfig struct {
|
|||||||
IdpSignKeyRefreshEnabled bool
|
IdpSignKeyRefreshEnabled bool
|
||||||
// Extra audience
|
// Extra audience
|
||||||
ExtraAuthAudience string
|
ExtraAuthAudience string
|
||||||
|
// AuthCallbackDomain contains the callback domain
|
||||||
|
AuthCallbackURL string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Host represents a Netbird host (e.g. STUN, TURN, Signal)
|
// Host represents a Netbird host (e.g. STUN, TURN, Signal)
|
||||||
|
|||||||
Reference in New Issue
Block a user