react-native-eks-auth

1.0.1 • Public • Published

react-native-eks-auth

A package for authenticating to AWS EKS clusters using IAM authentication from within a React Native environment without access to Node.js core modules.

Install

$ npm install --save react-native-eks-auth

Syntax

getBearerToken(clusterName, credentials)

This generates a bearer token which can then be used in the Authorization header of Kubernetes RESTful API requests to EKS clusters.

Example Usage

import { getBearerToken } from 'react-native-eks-auth';
import RNFetchBlob from 'rn-fetch-blob';
 
const apiFetch = async () => {
 
  const credentials = {
    accessKeyId: '<your-access-key-id>',
    secretAccessKey: '<your-secret-access-key>',
  }
 
  const token = getBearerToken('<cluster name>', credentials);
 
  const authHeader = {
    Authorization: `Bearer ${token}`,
  };
 
  const res = await RNFetchBlob.config({
    trusty: true, /* prevents self-signed certificate rejection */
  })
    .fetch('GET', 'https://<endpoint>.eks.amazonaws.com/<api path>', authHeader);
 
  return res.json();
}

Your AWS credentials (which can be found in your AWS console) are specified as the second argument in an object:

getBearerToken(clusterName, {
  accessKeyId: '<your-access-key-id>',
  secretAccessKey: '<your-secret-access-key>',
});

More Info

API Authorization from Outside a Cluster

Package Sidebar

Install

npm i react-native-eks-auth

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

23.2 kB

Total Files

7

Last publish

Collaborators

  • infiniti33