- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.3k
Add Azure oauth to databricks #15117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            Anshul759
  wants to merge
  6
  commits into
  datahub-project:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
Anshul759:UC-Ingestion-enhancements
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +238
        
        
          −13
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      5321f48
              
                feat: Add azure authentication for uc ingestions
              
              
                 3f4bf5f
              
                refactor: Fix imports orders
              
              
                 30445ea
              
                refactor: Format files
              
              
                 536b9ab
              
                refactor: Fix build lint issues
              
              
                 dac502c
              
                test: Add unit test cases
              
              
                 162cd0e
              
                Merge branch 'master' into UC-Ingestion-enhancements
              
              
                Anshul759 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
        
          
          
            13 changes: 13 additions & 0 deletions
          
          13 
        
  metadata-ingestion/src/datahub/ingestion/source/unity/azure_auth_config.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| from pydantic import Field | ||
|  | ||
| from datahub.configuration import ConfigModel | ||
|  | ||
|  | ||
| class AzureAuthConfig(ConfigModel): | ||
| client_secret: str = Field(description="Azure client secret") | ||
| client_id: str = Field( | ||
| description="Azure client (Application) ID", | ||
| ) | ||
| tenant_id: str = Field( | ||
| description="Azure tenant (Directory) ID required when a `client_secret` is used as a credential.", | ||
| ) | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -38,6 +38,7 @@ | |
| from datahub._version import nice_version_name | ||
| from datahub.api.entities.external.unity_catalog_external_entites import UnityCatalogTag | ||
| from datahub.emitter.mce_builder import parse_ts_millis | ||
| from datahub.ingestion.source.unity.azure_auth_config import AzureAuthConfig | ||
| from datahub.ingestion.source.unity.config import ( | ||
| LineageDataSource, | ||
| UsageDataSource, | ||
|  | @@ -159,20 +160,31 @@ class UnityCatalogApiProxy(UnityCatalogProxyProfilingMixin): | |
| def __init__( | ||
| self, | ||
| workspace_url: str, | ||
| personal_access_token: str, | ||
| warehouse_id: Optional[str], | ||
| report: UnityCatalogReport, | ||
| hive_metastore_proxy: Optional[HiveMetastoreProxy] = None, | ||
| lineage_data_source: LineageDataSource = LineageDataSource.AUTO, | ||
| usage_data_source: UsageDataSource = UsageDataSource.AUTO, | ||
| databricks_api_page_size: int = 0, | ||
| personal_access_token: Optional[str] = None, | ||
| azure_auth: Optional[AzureAuthConfig] = None, | ||
| ): | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. validation required -- if azure_auth is provided, all three fields (client_id, client_secret, tenant_id) must be present | ||
| self._workspace_client = WorkspaceClient( | ||
| host=workspace_url, | ||
| token=personal_access_token, | ||
| product="datahub", | ||
| product_version=nice_version_name(), | ||
| ) | ||
| if azure_auth: | ||
| self._workspace_client = WorkspaceClient( | ||
| host=workspace_url, | ||
| azure_tenant_id=azure_auth.tenant_id, | ||
| azure_client_id=azure_auth.client_id, | ||
| azure_client_secret=azure_auth.client_secret, | ||
| product="datahub", | ||
| product_version=nice_version_name(), | ||
| ) | ||
| else: | ||
| self._workspace_client = WorkspaceClient( | ||
| host=workspace_url, | ||
| token=personal_access_token, | ||
| product="datahub", | ||
| product_version=nice_version_name(), | ||
| ) | ||
| self.warehouse_id = warehouse_id or "" | ||
| self.report = report | ||
| self.hive_metastore_proxy = hive_metastore_proxy | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO client_secret should not be plain string