Skip to main content

boto3 plugin for S3 Ranger authorization

Project description

RAZ Client

RAZ Client python package provides plugin to boto3 library to use Apache Ranger for granular authorization for S3 access

Prerequisites

  • Python 3.10 or higher
  • Protocol Buffers version 7.34

Installation

To install using pip from the raz_client PyPI project:

$ pip install raz_client

Usage

  • The client assumes a kinited user session and will use the same principle to negotiate the authentication with the RAZ server.
  • Create a boto3 client of type s3.
    client = boto3.client("s3")
    
  • Create a configuration object of type configuration by importing it from the raz_python package.
    conf = Configuration()
    
  • Add the basic raz server configs by adding them via script or using a hadoop configuration file. Examples for both are present in the examples folder.
  • Configure the boto3 client by calling the configure_ranger_raz(client, conf) method from the raz_client lib.
  • The client is ready to be used as it is now.

Example

Look at the example directory for example usage of different options and different APIs.

Basic startup code for usage:

import boto3
import raz_client

client = boto3.client("s3")

# configure the client. The client uses the kerberos credentials of the logged in user for authorization
raz_client.configure_ranger_raz(client)

# To configure SSL certificate,
# 1. Download the certificate: CDP UI -> environment -> FreeIPA -> Get FreeIPA certificate
# 2. Configure the certificate path: 
# raz_client.configure_ranger_raz(client, ssl_file="<ssl_filepath>")
 
# list objects in bucket
result = client.list_objects(Bucket="<bucket name>", Prefix="/")
print(result)

List of Supported Operations


Configuration

The Configuration object provided can be used to pass additional parameters to the client. The user specified configs will override the raz server default configs.

Raz Constant

Key

Description

RAZ_URL_KEY fs.s3a.ext.raz.rest.host.url URL for the RAZ server along with port. There is no default value for this and is required by the user. Eg: https://raz_node:6082/
USE_SSL_VERIFICATION raz.client.use.ssl.verification Enable ssl verification on the client for talking to raz server for additional security. This config expects a True or False value. It is turned off by default.
SSL_CERT_LOCATION raz.client.ssl.cert.location Path to the SSL cert location. If the path is not set but USE_SSL_VERIFICATION is set to true the client will throw an error. For more info on the SSL Cert kind refer to this. This config expects the absolute path to the file.
RAZ_CLIENT_USE_DELEGATION_TOKEN raz.client.use.delegation.token Use delegation token for authenticating requests to RAZ Server. This means that on every request there won't be a kerberos handshake, making the authorization faster. Kerberos' authentication will still be required at the time of token creation and renewal. This config expects a True or False value.
RAZ_DELEGATION_TOKEN_VALIDITY raz.client.delegation.token.validity Validity of the delegation token, it is by default set to 15 minutes and can be increased or decreased. The client doesn't renew the delegation token asynchronously instead it renews the token on the request made after the expiry time. The value is set in seconds. Eg: To renew delegation token at 10 minutes set it to 10 * 60
RAZ_CLIENT_ENABLE_DEBUG_MODE raz.client.enable.debug.mode Enables the debug mode on the client. Set it to True to print all the debug info of the client.

License

Copyright (c) 2023 Cloudera, Inc. All Rights Reserved. This software and any associated use of this software is governed exclusively by the Cloudera Standard License included in the accompanying LICENSE.txt file or found at Cloudera License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

raz_client-1.1.1.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

raz_client-1.1.1-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file raz_client-1.1.1.tar.gz.

File metadata

  • Download URL: raz_client-1.1.1.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.8

File hashes

Hashes for raz_client-1.1.1.tar.gz
Algorithm Hash digest
SHA256 3c01b96ba4bd5e4dce457e677e856136828d7599632d9e73c6f023c5f2122e85
MD5 60799857ba8d24608661e2e4377c7479
BLAKE2b-256 66df6087c6f643fe99d79d59cacc59cdd023317596bb209088ea0c9b8b94c15a

See more details on using hashes here.

File details

Details for the file raz_client-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: raz_client-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.8

File hashes

Hashes for raz_client-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1b73a9a356033ef8e888656a8af09b782e963541e646523cc7f78056862a7c6
MD5 c7c9d059d9074357bedc9992a073b827
BLAKE2b-256 8f440834ebfae64b3c99b266449f8bd478c3cf59bf584344598364a6c60df0f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page