| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import json |
|
|
| import urllib3 |
|
|
| from minio import Minio |
| from minio.credentials import WebIdentityProvider |
|
|
|
|
| def get_jwt(client_id, client_secret, idp_client_id, idp_endpoint): |
| res = urllib3.PoolManager().request( |
| "POST", |
| idp_endpoint, |
| fields={ |
| "username": client_id, |
| "password": client_secret, |
| "grant_type": "password", |
| "client_id": idp_client_id, |
| }, |
| ) |
|
|
| return json.loads(res.data.encode()) |
|
|
|
|
| |
| idp_endpoint = ( |
| "https://IDP-HOST:IDP-PORT/auth/realms/master" |
| "/protocol/openid-connect/token" |
| ) |
|
|
| |
| client_id = "USER-ID" |
|
|
| |
| client_secret = "PASSWORD" |
|
|
| |
| idp_client_id = "MINIO-CLIENT-ID" |
|
|
| |
| sts_endpoint = "http://STS-HOST:STS-PORT/" |
|
|
| |
| role_arn = "ROLE-ARN" |
|
|
| |
| role_session_name = "ROLE-SESSION-NAME" |
|
|
| provider = WebIdentityProvider( |
| lambda: get_jwt(client_id, client_secret, idp_client_id, idp_endpoint), |
| sts_endpoint, |
| role_arn=role_arn, |
| role_session_name=role_session_name, |
| ) |
|
|
| client = Minio("MINIO-HOST:MINIO-PORT", credentials=provider) |
|
|
| |
| stat = client.stat_object("my-bucketname", "my-objectname") |
| print(stat) |
|
|