Access environment variables in native code - ios

My challenge is that I'm working on a public Flutter app and I don't want to expose my API keys in the source code. I'm specifically looking to inject the Google Maps API key into my AppDelegate.swift file.
Ideally I'd want to be able to pass this through with a .env file (and the then inject these keys as environment variables in CI/CD), but I'm also fine doing a --dart-define. I have not found any working example of how to get this working.
I'm able to get this working on the Android side of things without any issues.

You can save it as an plist dictionary, and add the reading code from the file. For example: https://stackoverflow.com/a/62916637/11798831
Also you could rename file by adding Bundle.main.path(forResource: "config", ofType: "env").object(...
You can do not commit it in the project, just keep it locally. Also add it as additional file in CI/CD.

Related

Set extension for Challenge file using getssl

I am using getssl to create a SSL from lets-encrypt. I think I have everything setup correct but am running into an issue with the Challenge file. The server I am using MVC on Windows on Liquid Web is not letting me use a file without an extension. If I add .txt to the challenge file it works correctly, so I know the file is accessable.
So I see two choices: First is to have getssl add a file extension to the Challenge file. Second is to allow files without extensions under MVC/Windows.
I have tried changing the web.config file and also looking for changes to the setting but neither have been fruitful.
http://my.site.com/.well-known/acme-challenge/WLasfaweaefqwwqetfgewfweqrtfwefwefsefasdfasdf_W1nuoZqCWbHTU
Found the answer here finally:
Letsencrypt acme-challenge on wordpress or asp.net mvc
Add the config file in the directory you want to download the file from.

Artifactory Change Base URL through file system

Plenty of advice on how to change the Base URL the Artifactory Pro is running on, Custom Base URL via Rest API, etc.
However, We need to change all instances of Base URL while application is not running. So if any instance of Base URL exists in file system or Mysql db, need to update accordingly.
Thanks for any assistance.
The answer to that is a bit tricky. You can have an 'artifactory.config.import.xml' file under your '$ARTIFACTORY_HOME/etc/' folder. By doing so Artifactory, upon starting will consume the file and import it as it's configuration file.
PLEASE READ THIS PART CAREFULLY: This is the tricky part, the import of this file will overwrite any existing configuration that you have on this Artifactory instance. Meaning that you have to hold the latest modified configuration before shutting down the instance.

How to protect sensitive data on CircleCi?

Where to store sencitive information like signing configs, api keys etc on Cicrle without adding them to git.
Normaly I dont upload such files to git repositories, but I dont see how can I use Circle without them
You would use private environment variables. This would be loaded into CircleCI via the webapp or API, and then injected into a running build. This way, sensitive information won't have to be stored in your repository.
Here's a doc on Environment Variables in CircleCI 1.0 and CircleCI 2.0.
Use environment variable. If you want to use file, encode it as base 64 string https://support.circleci.com/hc/en-us/articles/360003540393-How-to-insert-files-as-environment-variables-with-Base64
If you need to insert sensitive text-based documents or even small binary files into your project in secret it is possible to insert them as an environment variable by leveraging base64 encoding.
It seems CircleCI does not support sensitive file yet.

laravel 5.1 renaming file before uploading on s3

For safety reasons I would like to rename the files submitted to my application before uploading them to S3. For local storage I can use Storage::move afterwards. But for S3 I am having trouble. How do I do it? Also, instead of using move is it possible to rename them before storing? Right no my app renames the files without any actions to something like phpK69RGR.jpg May be I can just configure the random string method? I also tried using the php rename command before upload but my webservice started erroring out. I know its a very basic question but for some reason I am having trouble with it.
This is outlined in the docs.
$request->file('photo')->move($destinationPath, $fileName);
$fileName is an optional parameter that renames the file.
So with that, you could simply place this inside your controller:
//Generate random name
$fileName = str_random(30);
$request->file('photo')->move($destinationPath, $fileName);

possible to have a CocoaPods have a search path that includes the main app

This is my first time writing my own Cocoapod so this might be a really simple quedstion but ....
I am trying to use Cocoapods to distribute common code for a series of apps used within our company (the CocoaPod is called CommonHex with a prefix of HEX so HEXItem.h/m). However, we have a config file specific to each app called HOSTConfig.h/m. Is there any way to access this HOSTConfig.h/m from within our CommonHex pod?
It would seem like I should bOe able to have for example a config file which will have it's own values but would pull in for HOSTConfig.h/m if it exists? And would probably have to extend the search path or something.
So I have like:
MainApp
\-MainApp
\-HOSTConfig.h/m
CommonHex
\-Classes
\-HEXItem.h/m
\-HEXItemViewController.h/m
I would like this to be able to access HOSTConfig.h/m perhaps via another class where if HOSTConfig.h/m exists in the hosting app, it uses those values else it uses values in our CocoaPod
edit #1
so in CommonHex.podspec, I have the following but this doesn't seem to work:
s.source_files = "Classes", "Classes/**/*.{h,m}", "$(PROJECT_DIR)/HOSTConfig.{h,m}"
If what you are looking for is a way to access some header file(for config data) in your MainApp project from any Pod project, than the issue is just about providing proper path variable in pods project.
Just add
"$(PROJECT_DIR)/.."
along with the quotes to the User Header Search Paths entry build settings, and don't forget to select recursive.
This will allow the header search visibility of Pod to be extend to main project without changing the podfile.
Sample:
If you just want to read values for a configuration probably the best way is to have some plist file and then check from the pod if that exist in the bundle or default to the one in the pod.

Resources