Laravel accessing S3 bucket vs AWS Role - laravel

I have an EC2 instance that runs Laravel 5.1. I am using an S3 bucket through Laravel's api:
AMAZON_KEY=key
AMAZON_SECRET=secret
AMAZON_REGION=us-west-2
AMAZON_S3_BUCKET=my_app_bucket
But I already set up a ROLE that enables this box to use that particular bucket. Why do I also need a key and a secret? From an analysis of the code, it looks like Laravel always demands a key and a secret, so it would seem that I have to actually create an IAM user account with key/secret and use that for s3 access instead of using roles, which is preferred. Is there a way around this, or is this just how Laravel S3 access works?

A fix to use IAM credentials for filesystem, queue, and email was merged a few days ago, so upgrading to Laravel v5.1.7 should do the trick.
https://github.com/laravel/framework/pull/9558

Related

Is There Any Default Session Library in NextJS? Or what can we use instead of sessions?

What library can I use for NextJS? Is there any offical/default library except "next-session" or "iron-session"? Or what alternatives can we use instead of sessions in NextJS?
You can check this official NextJS docout for a list of auth providers in NextJS. It has a few great options listed like:
Auth0
Passport
Supabase
Supertokens
... and many more (probably should check out the list for selecting one that matches your requirements)
For temporary data storage try using one of these:
Redis
Amazon Elasticache
Memcached
BoltDB

Where to store the BigCommerce access token and other data

I am using laravel to build an app in BigCommerce. I am able to get access token but I need to store that for future requests. What is the best possible way to store the app data for BigCommerce?
I've got this working by creating a DB schema in Laravel where in there are tables like stores, users, app_settings.
Whenever the user installs an app, I am storing an access token and other information like store hash in stores table and user details in users table.
Whenever the app is loaded I could get the store and user information via verify signed request payload. Using this I am able to configure my app settings for the user and store those in app settings table.
So when I create a Webhook for the store, I could get the store hash from response as producer key and accordingly I can find the access token for the store using store hash in stores table.
If you're git ignoring your config.json or .env files, you could store these there. However after speaking with one of our Developer Advocates, I wanted to pass along some best practice advice. :) You may want to consider using a secrets manager for option #1 in your decision here. A secrets manager meaning a tool to safely store these variables like Secrets in Github or Key Vault in Azure.
Also, this resource may be helpful to review for your use case. https://www.codementor.io/#ccornutt/keeping-credentials-secure-in-php-kvcbrk55z

How to upload to YouTube without authorization

I need to check the uploaded videos on a YouTube Channel and then upload missing videos via a CRON JOB.
I first thing I tried was the REST API and the server response with the endpoint was moved.
The problem I ran into with the PHP Google API Client is that it requires the user to authorize the token.
I now tried using the Python Code, but it also requires a authorize session. Also when creating the OAuth 2.0 client ID we are suppose to use OTHER. And there is no OTHER.
Python quickstart
Any Ideas? This has been really frustrating as there does not seem to be a lot of examples other than the ones Google provides. I also could not find a rest equivalent. I do not care if the solution is python or Rest or PHP client. I just need a user less CRON job doing the work.
What you need to consider is that there are two types of data public data and private data.
Public data is not owned by any user. Videos on YouTube for example for the most part are publicly available and do not require authorization to access. On the other had private data is data that is owned by a user.
In order to access public data you just need an api key to identify your application, however in order to access private user data you need the permission of the user who owns the account in question.
In order to upload to a users account (yes even your own) you need to be authenticated there for you will need to use Oauth2 yes even if you are using a cron job you still need to be authenticated there is no way around this. There for you will need to create Oauth2 credentials.
What i recommend you do is. Authorize your code once your your local machine store the refresh token and use the refresh token to request a new access token when ever your cron job needs access. I recomend you give that a try and if you have any issues create a new question include your code and a description of the problem you are having.
This is your only option with the YouTube API.

How to fetch device list from my database when linked my skill using LWA in aws lambda?

I had linked my smart home skill using LWA 'Login with Amazon'. It is working perfectly. My question is how to fetch the device list which is stored in my database. I get the bearer token for each directive call. But I don't know how to use that bearer token to get the device list from my database during Discovery directive.
I have my own smart home app where the user creates account and login to get the device list. User adds a device via my app.
For fetching your data from your database assuming you are using AWS RDS you can use
the AWS Lambda service.
Try this link:
https://aws.amazon.com/blogs/database/query-your-aws-database-from-your-serverless-application/#Step_6._Query[Query your AWS database from your serverless application][1]

Using AWS Ruby SDK, how can one get the current user's details?

As can be seen in this question, the Java SDK has a method to retrieve the current user based on the request's credentials. Is there a way to do something similar using the Ruby SDK?
I've tried AWS::IAM.new(creds).access_keys[creds[:access_key_id]], but that returns a simple object that answers nil to user or user_name, and my user doesn't have the iam:ListUsers permission so I can't enumerate the users collection.
Basically I need that information because I want to generate a self-approving policy to be attached to some new resources, and I need to fetch the ARN that my configured access key is associated with. Any suggestions?
You can get the current user using the client class. If you are using version 1 of the AWS SDK for Ruby, the aws-sdk gem:
iam = AWS::IAM::Client.new
iam.get_user
If you prefer to use the new version 2 AWS SDK for Ruby, just change the root namespace from AWS to Aws:
iam = Aws::IAM::Client.new
iam.get_user

Resources