Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added basic authentication #76

Merged
merged 1 commit into from
Mar 16, 2016
Merged

Conversation

morph027
Copy link

I'm proof-concepting to upload packages from a CI of your favourite choise to a aptly repo. As these are not compulsory on the same host (e.g. Travis CI/Gitlab CI/Drone/... to a private repo), the API is protected using basic authentication at the moment. Therefore i've added 2 new config values and the HTTParty option including README update.

By the way: Thanks for your gem ;)

@@ -12,6 +12,12 @@ class AptlySnapshot
config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
base_uri "http://#{config[:server]}:#{config[:port]}/api"

if config[:username]
if config[:password]
basic_auth "#{config[:username]}", "#{config[:password]}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

@sepulworld
Copy link
Owner

Thanks @morph027 for the PR! Ill check it out. What is the best way to test this? Perhaps setup a private Travis CI account to upload into?

@morph027
Copy link
Author

I'll just put a nginx instance as reverse proxy in front of the API like this simple snippet:

server {
    listen 80;

    root /nowhere;

    location /api/ {
        client_max_body_size 100M;
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/.htpasswd.aptly;
        proxy_redirect  off;
        proxy_pass  http://localhost:8080/api/;
        proxy_redirect  http://localhost:8080/api/ /api;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Origin "";
    }
}

Then create a .htpasswd:

htpasswd -c /etc/nginx/.htpasswd.aptly repo-api

Let nginx access it:

chown www-data: /etc/nginx/.htpasswd.aptly

Then you should be able to access it on port 80 using basic auth.

@sepulworld
Copy link
Owner

Ok great! I'll use this to generate the VCR mock data to test with. After I
add the tests I'll merge and release new gem version

On Mon, Mar 14, 2016, 12:21 PM morph027 notifications@github.com wrote:

I'll just put a nginx instance as reverse proxy in front of the API like
this simple snippet:

server {
listen 80;

root /nowhere;

location /api/ {
    client_max_body_size 100M;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd.aptly;
    proxy_redirect  off;
    proxy_pass  http://localhost:8080/api/;
    proxy_redirect  http://localhost:8080/api/ /api;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header Origin "";
}

}

Then create a .htpasswd:

htpasswd -c /etc/nginx/.htpasswd.aptly repo-api

Let nginx access it:

chown www-data: /etc/nginx/.htpasswd.aptly

Then you should be able to access it on port 80 using basic auth.


Reply to this email directly or view it on GitHub
#76 (comment).

-Zane

sepulworld added a commit that referenced this pull request Mar 16, 2016
@sepulworld sepulworld merged commit 9e82017 into sepulworld:master Mar 16, 2016
@sepulworld
Copy link
Owner

Thank you for your contribution!

Merged and updated gem version to 0.2.2
https://rubygems.org/gems/aptly_cli/versions/0.2.2

@morph027 morph027 deleted the basic-auth branch March 16, 2016 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants