Code Monkey home page Code Monkey logo

aws-samples / content-repository-with-dynamic-access-control Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 1 MB

Code and walkthrough to build an end-to-end content repository for unstructured data with dynamic access control.

Home Page: https://aws.amazon.com/blogs/architecture/content-repository-for-unstructured-data-with-multilingual-semantic-search-part-1/

License: MIT No Attribution

JavaScript 14.54% Python 20.15% TypeScript 61.45% HTML 1.38% CSS 2.48%
architectural-patterns aws cdk security unstructured-data

content-repository-with-dynamic-access-control's Introduction

Content Repository With Dynamic Access Control

This example walks you through how to build an end-to-end content repository using AWS services with a simple and dynamic access control based logic over unstructured data. This sample includes an AWS Cloud Development Kit (CDK) application to deploy the architectural foundation for the content repository as depicted in the diagram below. A simple react web UI to upload and list documents completes this demo environment. Further details can be found in this related AWS architecture blog post. The code is not meant for production workloads.

image info


Stability: Stable

This is a stable example. It should successfully build out of the box.

This prototype is built on CDK construct libraries marked "stable" with the exception of amplify_alpha but thoroughly tested.

Prerequisites

You should have the following prerequisites to deploy the content repository with demo data:

Deployment

Clone the project git repository:

git clone https://github.com/aws-samples/content-repository-with-dynamic-access-control

Install the necessary dependencies:

cd content-repository/backend-cdk
npm install

Configure environment variables::

export CDK_DEFAULT_ACCOUNT=$(aws sts get-caller-identity --query 'Account' --output text)
export CDK_DEFAULT_REGION=$(aws configure get region)

Bootstrap your account for AWS CDK usage:

cdk bootstrap aws://$CDK_DEFAULT_ACCOUNT/$CDK_DEFAULT_REGION

Deploy the code to your AWS account:

cdk deploy --all

This deploys two CDK stacks into your AWS account. The BlogContentRepositoryStack (content-repo-stack) creates the architecture and the DemoDataStack (demo-data-stack ) deploys sample users, groups and role mappings.

Example walkthrough

  1. Access the front-end application
    • Copy the value of the amplifyHostedAppUrl shown in the CDK output from the content-repo-stack.
    • Use the URL with your web browser to access the front-end application. You will see a temporary page until the automated build and deployment of the react application has been finished which takes a few minutes.
  2. Application sign-in and role-based access control
    • The react webpage asks you to sign in first, then change the temporary password. You can find two demo users with credentials created as part of the demo-data-stack in the CDK output. In this walkthrough, we use the sales-user which belongs to the sales department group to validate RBAC.
  3. Upload a document to the content repository
    • Authenticate as sales-user, then go ahead and upload your first document via the “upload” button to the content repository. You can find sample documents in the assets sub-folder from the cloned repository.
  4. List your uploaded document
    • Post successful upload process, click on the “list” button to show the upload sales content.
    • You can verify the dynamic access control by repeating the step 2 and 3 for the marketing-user belonging to the marketing department group. Additionally log into the AWS console and navigate to the S3 bucket with the prefix content-repo-stack-s3sourcebucket to check that all the uploaded content exists.

Outlook

From here on you have the foundation to implement more complex access control use cases for the users of your departments by finding the right balance between IAM role and principal tags. For example, you can use Cognito user pool custom attributes for additional dimensions such as document “clearance” with optional modification in the pre token generation Lambda.

Cleaning up

In the subdirectory “backend-cdk”, delete the deployed resources:

cdk destroy –all 

Useful commands

  • cdk ls list all stacks in the app
  • cdk synth emits the synthesized CloudFormation template
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk docs open CDK documentation

Enjoy!

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

content-repository-with-dynamic-access-control's People

Contributors

amazon-auto avatar nagelpat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

muneer0072000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.