IP filtering on Google Cloud run - google-cloud-run

I have an Angular web app i want to deploy using Google Cloud run. However I need the app be visible only from a list of predefined IP addresses.
Can I simply set the ip allow/deny rules under Google cloud platform firewall or do I need another method?
Thanks in advance,
Nico

Google is clear about this point:
Don't trust the network
By the way, the Google top priority in development don't rely on IP origin but on token for identity and authorization.
For Cloud Run, you have Google Front End (GFE) which act as proxy, check the authentication (in case of private Cloud Run), ensure that the SSL certificate is deployed and valid,... It's not possible to customize it with IP filtering
Even if you plug a Endpoint (ESP) gateway in front of your Cloud Run service, it is not possible to filter on IP among all the security method. The easiest for your should be to use API key, I wrote an article on this
In the futur, Cloud Run will be compliant with Loadbalancer. Not sure that will be enough for filtering IP.
All of this for telling you that, if you want to implement IP filtering in top of Cloud Run (and Cloud Function), you have to implement it by yourself.

There is currently no way to make Cloud Run accessible only for certain IPs.
However, Cloud Run services are deployed privately by default and are secured by IAM.
If you need to authenticate users, the provided ways are to use Google Sign-In or, should you want to use other credentials, Identity Platform or Firebase Authentication

Related

Set a Role Condition to invoke a Cloud Run service

I want to enable a service account to invoke a Cloud Run service and restrict the invocation to a specific URL (eg.: https://myservice/specific).
Most of GCP resources allow for conditional restrictions using IAM Conditions (like picture below).
I'm wondering if Cloud Run does support IAM Conditions, and I case it does not what's the recommended way to achieve such kind of restriction.
Thanks.
IAM service is a free Google Cloud product that manage IAM access for Google Cloud product.
That being said, go back to your case: You have a service account that you want to restrict (or allow) the access to Cloud Run product. No problem, you can grant the run.invoker role to access to Cloud Run.
If you want finer/inner Cloud Run service permission, you should guess that it is not possible with IAM service. Indeed, the inner permission (or business permission) are specific to your code, and not to the Google Cloud code (i.e. the Google Cloud products).
And IAM Conditions won't help you in that case. IAM Conditions applies on Google Cloud product definition. For instance, you can grant a service account to access to Cloud Run services with the service name starting by something. But again, it's only on Google Cloud product information.
IAM can't help you on that. You could have a look at API Gateway. Or, you should have to implement the checks directly in the /path code to filter the authorized calls.
Based on this link, you can grant your Service Account a "Cloud Run Invoker" role.
You can read this link for more information.
I've tried to add the role "Cloud Run Invoker" to a user and it works. Just try it to a service account.
The service accountIAM permission,you can achieve this while deploying/editing a service you have the option to select "Allow only authenticated requests". This would basically do two things, one is restrict access to users listed within the IAM permissions list of the project. Secondly, you'd be able to give invocation permissions to email addresses and/or email domains Documentation here.As also can be inferred from the documentation here, frontend can securely and privately invoke backend by leveraging the Invoker IAM role:
Grant the service account of frontend the Cloud Run Invoker IAM role.
When you issue request from frontend to backend, you must attach an identity token to the request, see here for code examples
While there are other options to authenticate to Cloud Run services whose "Require authentication" option is turned on, all of the options issue and use a Google-issued token one way or another. That's because the option "Require authentication" uses IAM to secure Cloud Run services

Restrict access to Microsoft Graph based on IP

I'm using Microsoft Graph API to access data from my Azure AD, including adding and updating users.
Is there any way I can limit access to the Graph API based on the client's IP? So that requests originating from a specific IP or an IP range will be served, and the rest will be blocked?
As far as I understand, Graph API deployment https://graph.microsoft.com is a public API that is protected by Azure AD. As long as you have a valid access token you are able to call the API and do what the access token says you are allowed to do regardless of where you are. This means access restriction can only be done at Azure AD level during authorization.
If you apps are user interactive then you can try using Azure AD Conditional Access Location Condition.
For daemon apps that run on server-side, this case may not apply because they run behind your trusted networks in most cases.

Exclude cloud run from outer internet

I have backend and google endpoints service (both on cloud run). Endpoints service provides information from backend for authorized users. I want to make backend not accessible from outer internet. There are possibility to allow only inner connections by setting Ingress -> Allow internal traffic only. If I do that my endpoints service can't reach backend. All endpoints and backend connected to the same VPC. How can I exclude backend from outer internet? how I want it be
You have 2 solutions:
Continue to expose your backend service to the internet but make it secures (IAM protected service, deployed with --noallow-unauthenticated option). However, grant only the service account of your endpoint service to reach the backend. Like that all the unauthenticated and the unauthorized traffic will be filtered by GFE (Google Front End) and discarded automatically. Only allowed traffic will reach the backend. That solution has the advantage to allow you to also test the backend in case of issue for example, with the correct permissions.
The second solution is exactly what you want:
Set the backend ingress to internal only
Create a serverless VPC connector, add it to the endpoint service with the egress control to ALL.
Like that, all the traffic of the endpoint will be routed through the VPC connector, land in your VPC and then, internally access your backend. Why egress=all?? Because, even if you set your backend ingress to internal, the Cloud Run URL is still public (but an additional check is done to be sure that the traffic comes from your VPC, it's named authenticated network traffic)
At the end, it's always authentication based (on network source or on service account identity). The serverless VPC connection costs about $17 per month

AWS Elasticesearch from ios application

I am using AWS ES for the search on my iOS application. As of now, I use the Rest API for the serving the search queries to the application. The app calls the Rest API and my python server searches to serve the requests. I want to eliminate this Rest API server and want to implement the interaction between iOS and AWS ES directly. AWS iOS SDK does not provide service for ES. What shall I do for that?
I have looked into these resources but did not get much clarity,
Elasticsearch access policy - allow read from clients and read/write from Node.js server
How to secure access to AWS Elasticsearch from a mobile application
Any help would be appreciated.
You can make use of AWS Cognito, User Pools and Federated Access to provide fine grained access to AWS resources to your set of users.
Read more at this link: Secure API Access with Amazon Cognito Federated Identities, Amazon Cognito User Pools, and Amazon API Gateway
I won't recommend doing this though, especially for elastic search cause if any of the temporary credentials (STS tokens) are stored in an in-secure place (not a keychain), users will be able to delete or create indices on your elastic search cluster, as AWS does not provide fine grain control over the APIs exposed by elasticsearch itself.
To solve this problem, you can use API Gateway as a proxy to only the search endpoints of the indices you want to allow your clients to be able to search. You do not need a Lambda function or any EC2 instance in the middle to achieve this.

wso2am: Giving the end user the ability to revoke access

I'm working on my master where I have to design and prove a solution to expose some university legacy services. None of them have controlled access, so other feature needed is this security layer.
To make this possible I'm using wso2 products: wso2ebs to make some orchestration and messaging transformation; wso2is to connect to a shibboleth idp that already exists; and wso2am to put everything together and expose the services.
I already have the identity provider (Shibboleth) configured on wso2is. I use this http://xacmlinfo.org/2014/12/10/federation-testshib/ to prove it.
To make the authentication layer, I'm not sure but I think that I can use this http://wso2.com/library/articles/2015/03/bring-your-social-identity-to-perform-organizational-authorization-actions-with-wso2-identity-server/ to make the bond between wso2is and wso2am.
But there is a use case I can't solve: wso2am give me an oauth like environment to expose my private services, but how can a student (end user) manage is authorisations? I as a student which use a mobile app that consume information given by an api exposed by wso2am, want to revoke this this authorisations given previously to this mobile app. How can I do this?
TLDR:
If wso2am use an oauth like environment to expose apis, is there a way to the end user revoke an authorisation given previously to an mobile app that make use of an api exposed by wso2apim?
There are two options
If you have client_id, Secret and access token on your hand you can use https://docs.wso2.com/display/AM190/Token+API revoking access tokens part
If not you can use revokeAuthzForAppsByResoureOwner operation in OAuthAdminService

Resources