Skip to content
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

feat: Jupyterhub cognito fine grained access control #380

Merged
merged 7 commits into from
Dec 8, 2023

Conversation

dorukozturk
Copy link
Contributor

What does this PR do?

This PR creates a cognito identity pool, creates an iam role that is tied to the cognito user and injects credentials to the spawner using auth hooks. This way customers can manage all of their users through cognito and assign iam roles to the notebooks themselves for principle of least privilege.

🛑 Please open an issue first to discuss any significant work and flesh out details/direction - we would hate for your time to be wasted.
Consult the CONTRIBUTING guide for submitting pull-requests.

Motivation

More

  • Yes, I have tested the PR using my local account setup (Provide any test evidence report under Additional Notes)
  • Mandatory for new blueprints. Yes, I have added a example to support my blueprint PR
  • Mandatory for new blueprints. Yes, I have updated the website/docs or website/blog section for this feature
  • Yes, I ran pre-commit run -a with this PR. Link for installing pre-commit locally

For Moderators

  • E2E Test successfully complete before merge?

Additional Notes

@dorukozturk dorukozturk changed the title Jupyterhub cognito fine grained access control feat: Jupyterhub cognito fine grained access control Dec 5, 2023
Copy link
Collaborator

@vara-bonthu vara-bonthu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏼

Copy link
Collaborator

@askulkarni2 askulkarni2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorukozturk PR is fantastic and much needed by customers.

Just some minor notes but otherwise looking great.

}
}

resource "aws_lambda_function" "pretoken_trigger" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create only if cognito is used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var.jupyter_hub_auth_mechanism == "cognito" ? 1 : 0 @dorukozturk

})
}

resource "aws_iam_role_policy" "s3_cognito_engineering_policy" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create only if cognito is used.

EOF
}

resource "aws_cognito_identity_pool_provider_principal_tag" "example" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create only if cognito is used.

}
}

resource "aws_iam_policy_attachment" "s3_readonly_policy_attachment" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create only if cognito is used.

roles = [aws_iam_role.cognito_authenticated_engineering_role[0].name]
}

resource "aws_cognito_identity_pool_roles_attachment" "identity_pool_roles" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create only if cognito is used.


cognito_config.py: |-
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool!!

@lusoal this is similar to what we discussed at KubeCon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very similar to what we have discussed, congrats on the PR @dorukozturk amazing

Copy link
Contributor

@lusoal lusoal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
}

resource "aws_lambda_function" "pretoken_trigger" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var.jupyter_hub_auth_mechanism == "cognito" ? 1 : 0 @dorukozturk


cognito_config.py: |-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very similar to what we have discussed, congrats on the PR @dorukozturk amazing

@dorukozturk
Copy link
Contributor Author

I added the conditionals ! Thanks for all the kind words and fast reviews :)

Copy link
Collaborator

@askulkarni2 askulkarni2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dorukozturk
Copy link
Contributor Author

Fixed the index errors

@vara-bonthu vara-bonthu merged commit 10a475f into awslabs:main Dec 8, 2023
46 of 47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants