mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-23 08:33:45 +01:00
7794b744f8
Enhance the user experience by enabling authentication to Netbird using Single Sign-On (SSO) with any Identity Provider (IDP) provider. Current client offers this capability through the Device Authorization Flow, however, is not widely supported by many IDPs, and even some that do support it do not provide a complete verification URL. To address these challenges, this pull request enable Authorization Code Flow with Proof Key for Code Exchange (PKCE) for client logins, which is a more widely adopted and secure approach to facilitate SSO with various IDP providers.
63 lines
2.6 KiB
Go
63 lines
2.6 KiB
Go
package mock_server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/netbirdio/netbird/management/proto"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
type ManagementServiceServerMock struct {
|
|
proto.UnimplementedManagementServiceServer
|
|
|
|
LoginFunc func(context.Context, *proto.EncryptedMessage) (*proto.EncryptedMessage, error)
|
|
SyncFunc func(*proto.EncryptedMessage, proto.ManagementService_SyncServer)
|
|
GetServerKeyFunc func(context.Context, *proto.Empty) (*proto.ServerKeyResponse, error)
|
|
IsHealthyFunc func(context.Context, *proto.Empty) (*proto.Empty, error)
|
|
GetDeviceAuthorizationFlowFunc func(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error)
|
|
GetPKCEAuthorizationFlowFunc func(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error)
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) Login(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
|
|
if m.LoginFunc != nil {
|
|
return m.LoginFunc(ctx, req)
|
|
}
|
|
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) Sync(msg *proto.EncryptedMessage, sync proto.ManagementService_SyncServer) error {
|
|
if m.SyncFunc != nil {
|
|
return m.Sync(msg, sync)
|
|
}
|
|
return status.Errorf(codes.Unimplemented, "method Sync not implemented")
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) GetServerKey(ctx context.Context, empty *proto.Empty) (*proto.ServerKeyResponse, error) {
|
|
if m.GetServerKeyFunc != nil {
|
|
return m.GetServerKeyFunc(ctx, empty)
|
|
}
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetServerKey not implemented")
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) IsHealthy(ctx context.Context, empty *proto.Empty) (*proto.Empty, error) {
|
|
if m.IsHealthyFunc != nil {
|
|
return m.IsHealthyFunc(ctx, empty)
|
|
}
|
|
return nil, status.Errorf(codes.Unimplemented, "method IsHealthy not implemented")
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) GetDeviceAuthorizationFlow(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
|
|
if m.GetDeviceAuthorizationFlowFunc != nil {
|
|
return m.GetDeviceAuthorizationFlowFunc(ctx, req)
|
|
}
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetDeviceAuthorizationFlow not implemented")
|
|
}
|
|
|
|
func (m ManagementServiceServerMock) GetPKCEAuthorizationFlow(ctx context.Context, req *proto.EncryptedMessage) (*proto.EncryptedMessage, error) {
|
|
if m.GetPKCEAuthorizationFlowFunc != nil {
|
|
return m.GetPKCEAuthorizationFlowFunc(ctx, req)
|
|
}
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetPKCEAuthorizationFlow not implemented")
|
|
}
|