Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding OAuth consumer secret in public github repository and other sensitive data

I want to make a private Github repo public, but the project includes OAuth data (used in Twitter auth) and database MySQL login details. Is there a common practise to easily hide the values or shall I just change them when committing to the repo? I guess thats the reason I'm asking as I'm likely to forget.

like image 403
daihovey Avatar asked Mar 26 '12 07:03

daihovey


People also ask

How do I hide a secret key in GitHub?

The only way to hide it is to proxy your request through your own server. Netlify Functions are a free way to add some simple backend code to a frontend app. This is this method I used while learning to program in college, where I needed to share my progress with my peer group without disclosing my API keys.

Why is a bad idea to commit secret data into a git repository?

Because Git is distributed, other developers may preserve your secret in their own local copies of the repo. Of course, there's also the risk that your source code is leaked: in many cases this is a bad thing on its own, and it only gets worse if your repository contains any password or secret.

What is the purpose of GitHub secrets?

You could use GitHub secrets to store your Azure Credentials, Publish profile of your Web app, container registry credentials or any such sensitive details which are required to automate your CI/CD workflows using GitHub Actions.

Who can see GitHub secrets?

GitHub ties repository secrets to only one repository. They're available to anyone with the collaborator role to use in actions.


1 Answers

If you can rewrite the history of your private repo (because of the limited number of collaborators), it would be best to:

  • remove completely from the all history those sensitive data
  • store them "elsewhere" (ie not in a Git repo but in an external source)
  • use content filter driver to manage your actual sensitive file content.
    See "What's the easiest way to deal with project configuration files?" for instance:

content filter driver

The idea is, on checkout, to generate the actual files based on:

  • your environment
  • a template file
  • a value file (which can be, based on your current environment, dummy values store in a separate value file in your Git repo, or your actual sensitive value stored in your external source outside the Git repo)

The more general idea is that sensitive data shouldn't be stored at all in a Git repo.

like image 108
VonC Avatar answered Oct 05 '22 00:10

VonC