Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Basic Auth Configuration #45

Merged
merged 17 commits into from
Apr 3, 2019
Merged

Basic Auth Configuration #45

merged 17 commits into from
Apr 3, 2019

Conversation

randallagordon
Copy link
Contributor

@randallagordon randallagordon commented Aug 29, 2016

What's this PR do?

Adds the ability to configure Basic Authentication.

Will generate .htpasswd if environment variables BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD are present; otherwise use an .htpasswd file present in the app directory.

To configure, in static.json:

{
  "basic_auth": true
}

Background

Closes #43, where Basic Auth support was requested by @josephabrahams.

@randallagordon
Copy link
Contributor Author

Thank you @donbobka for fixing the tests and doing some general improvements!

@randallagordon
Copy link
Contributor Author

Just wanted to follow up and check if there's anything else blocking this from being merged?

@paulmsmith
Copy link

paulmsmith commented Nov 28, 2016

I can't get this to work. I've forked it and used it. I'm presented with basic-auth username and password but it doesn't seem to recognise the username and password.

I assumed if I set config vars within heroku for BASIC_AUTH_USERNAME and BASIC_AUTH_PASSWORD that was all I'd need to do.

In the logs I see: user "dev-dwp-design": password mismatch

@donbobka
Copy link

@paulmsmith, BASIC_AUTH_PASSWORD must be a hash of your password. Use command openssl passwd -apr1 to hash your password

@paulmsmith
Copy link

@donbobka Oh of course! Thanks for the mighty swift reply!

@paulmsmith
Copy link

paulmsmith commented Nov 28, 2016

@donbobka Actually, still not working. Where am I supposed to stored the hashed password? In the config vars? (Long day! :))

Edit. I think I was being dumb... will post back......

@paulmsmith
Copy link

@donbobka I was being dumb. I paste the username and hashed that. Thank you for the work. Hopefully will make it in to the final repo.

@ghost
Copy link

ghost commented Dec 8, 2016

I've been using this for almost a month now in our 2 pre-production environments with great success.

https://github.com/Aculeus/create-react-app-buildpack/blob/master/.buildpacks

@dcarral
Copy link

dcarral commented Jan 11, 2017

Hi @hone, what do you think about these changes? ;)

@ianstormtaylor
Copy link

Hey @randallagordon I'm trying to use this via your branch, but for some reason even when adding BASIC_AUTH_PASSWORD and BASIC_AUTH_USERNAME, no .htpasswd file is created on new deploys. And even if I manually add the .htpasswd file myself, it's still not picked up.

I have a feeling the buildpack isn't actually taking effect, even though I've run:

heroku buildpacks:set https://github.com/doinginc/heroku-buildpack-static.git#basic-auth

(I've also tried...)

heroku buildpacks:set https://github.com/doinginc/heroku-buildpack-static#basic-auth

Anyone know why?

@randallagordon
Copy link
Contributor Author

@ianstormtaylor it should work with or without the .git in the URL—I'm using it on two Heroku apps currently and inadvertently used the different variations on each! If you're using multiple buildpacks, it needs to be the last buildpack to execute. That's the only thing I can think of to check at the moment.

@bartocc
Copy link

bartocc commented Mar 6, 2017

Is there anything holding this PR to be merged ?

Thx

@wolovim
Copy link

wolovim commented May 8, 2017

Happy Monday! I'd love to see this feature. Could today be the day? /bump

@viperfx07
Copy link

TGIF! I'd love to see this feature as well. Could today be the day? /bumpagain

@josercruz01
Copy link

Ping! Any plans on when this will be merged? We could use it to add basic auth to our review apps. /bumpagain

@jeremieca
Copy link

Ping

@moha297
Copy link

moha297 commented Jun 18, 2017

Why are we not merging this PR?

@viperfx07
Copy link

I merged it manually on my repo, https://github.com/viperfx07/heroku-buildpack-static, just in case anyone needs it.

Cheers

@gabrielperales
Copy link

gabrielperales commented Dec 4, 2017

Hi @viperfx07, I'm using your fork, and I'm having an issue. I'm getting a 401 error when I request my backend through a proxy. Is anyone having the same issue? Or anyone knows how I can fix it?

@coffenbacher
Copy link

Why has this PR been open since 2016 with no justification for not being merged? Can't be inspiring for contributors... 😬

@cancan101
Copy link

Ping on this? Would be great to have this!

@BevanR
Copy link

BevanR commented Aug 21, 2018

@hone This is well tested by the community. It would be great to get it in.

@patcon
Copy link

patcon commented Sep 5, 2018

Related: #111

@ludwiktrammer
Copy link

@Dhaulagiri @hone Are there any updates on this?

nicolov added a commit to nicolov/heroku-buildpack-static that referenced this pull request Feb 18, 2019
@felipemalinoski
Copy link

Please move this forward, there're so many forks in this repo because of this small feature!

Listen to your users

/cc @Dhaulagiri @hone

@Dhaulagiri Dhaulagiri merged commit bde9522 into heroku:master Apr 3, 2019
@bartocc
Copy link

bartocc commented Apr 4, 2019

thx @Dhaulagiri 🎉

tangrufus added a commit to tangrufus/heroku-cli-static that referenced this pull request Apr 4, 2019
Because heroku/heroku-buildpack-static#45 looks for `/app/.htpasswd` when:
- `"basic_auth": true` (`static.json`), and
- `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD` are not set
@cancan101
Copy link

Is there any way to enable / disable basic auth based on an env var?

@patcon
Copy link

patcon commented Apr 29, 2019

@cancan101 I'd recommend starting a new issue for this support/feature request <3

wgrrrr added a commit to urllo/heroku-buildpack-static that referenced this pull request May 13, 2019
* upstream/master:
  Basic Auth Configuration (heroku#45)

# Conflicts:
#	scripts/config/templates/nginx.conf.erb
mikaelbartlett pushed a commit to nixonnixon/heroku-buildpack-static that referenced this pull request Apr 4, 2021
* Basic Basic Auth

* Allow username and password to be passed in via env vars

* Add test spec for basic auth returning 401

* Update README with Basic Auth config info

* Add .htpasswd to test fixture

* Set env vars in test

* Request the file that actually exists, maybe?

* Is context the key?

* Perhaps app.run needs to come to the party too?

* Move `auth_basic` from `location` to `server`

* Set `basic_auth` as true if env `basic_auth_username` exists

* Fix htpasswd generation when basic_auth is false

* Append env password instead truncating

* Fix typo

* Fix config example in README
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Basic Auth Configuration