Create RBACK decorator in fast Api to intercept the JWT Token, extract the user_id and get the roles and match it with the roles defined for that particular REST API.
https://github.com/vineetkarandikar/aws-samples/blob/main/auth.py
Create RBACK decorator in fast Api to intercept the JWT Token, extract the user_id and get the roles and match it with the roles defined for that particular REST API.
https://github.com/vineetkarandikar/aws-samples/blob/main/auth.py
Below is the command to generate models from database directly in quick fashion.
$ pip install sqlacodegen
$ pip install pymysql
Create your db schema.
now issue the following command
$ sqlacodegen mysql+pymysql://Nich:Bossdk#@localhost/dev
the output will be like given below
class User(Base):
__tablename__ = ‘user’
user_id = Column(Integer, primary_key=True)
first_name = Column(String(255), nullable=False)
last_name = Column(String(255))
email_id = Column(String(255), unique=True)
phone_no = Column(BigInteger)
country = Column(String(50))
_pass = Column(‘pass’, String(255))
S3-Object Listing-filter by date
https://github.com/vineetkarandikar/aws-samples/blob/main/s3_object_list_filter_by_date.py
Run the following commands
npm install -g serverless
serverless config credentials --provider aws --key XXXXXXXXXEXAMPLE --secret XXXXXXXXX/XXXXXXX/XXXXXXXXX
Also make sure the IAM user for which we would be using aws key and secret should have following policies attached
serverless create — template aws-nodejs — path hello-world-medium
cd hello-world-medium
serverless deploy -v
I created the lambda function to generate access token and id token as mentioned in my previous blogs.The access token we decoded will show something like.
{
“sub”: “5ccc31a1–4934–455f-8d83–1ec4b49b1df2”,
“cognito:groups”: [
“user”
],
“event_id”: “e4308419–92da-49e5–961a-b3df624e3c40”,
“token_use”: “access”,
“scope”: “aws.cognito.signin.user.admin”,
“auth_time”: 1610342817,
“iss”: “https://cognito-idp.us-east-1.amazonaws.com/us-west-1_b4b1HPlo8",
“exp”: 1610346417,
“iat”: 1610342817,
“jti”: “83abd9c1–1a08–41af-bc37-d6d64a68d7e6”,
“client_id”…