Skip to content

Commit

Permalink
Merge pull request #27 from igormukhingmailcom/master
Browse files Browse the repository at this point in the history
Added: Ability to provide HTTP Basic Auth credentials
  • Loading branch information
kosssi committed Jan 12, 2016
2 parents 1bc89a0 + cee645a commit 1f1dd20
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ You can also setup a global composer directory and make the bin directory availa
composer_global_packages:
phpunit/phpunit: "@stable"

## Auth.json

### Github OAuth token

If your project use a lot of libraries from github, you may see next message during `composer install`:

Could not fetch `...`, enter your GitHub credentials to go over the API rate limit
Expand All @@ -35,6 +39,17 @@ To prevent that, you must configure github oauth token to go over the API rate l

composer_github_oauth: f03401aae1e276abb073f987c08a32410f462e73

### HTTP Basic auth

You can provide HTTP Basic auth credentials to any repository like this:

```
composer_http_basic:
repo.magento.com:
username: 52fe41da9d8caa70538244c10f367d0a
password: 238fe32d374a2573c4527bd45a7e6f54
```

## Example Playbook

roles:
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ composer_global_packages: {}
# Visit https://github.com/settings/applications
# and generate personal access token
composer_github_oauth: false
composer_http_basic: false
2 changes: 1 addition & 1 deletion tasks/oauth.yml → tasks/auth_json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
template:
src: ".composer/auth.json.j2"
dest: "{{ composer_home_path|default('~/.composer') }}/auth.json"
when: composer_github_oauth != false
when: composer_github_oauth != false or composer_http_basic != false
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
- include: install.yml
- include: test.yml
- include: configure.yml
- include: oauth.yml
- include: auth_json.yml
- include: update.yml
when: composer_update == true
18 changes: 16 additions & 2 deletions templates/.composer/auth.json.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"github-oauth": {
"github.com": "{{ composer_github_oauth }}"
{% if composer_http_basic %}
"http-basic": {
{% for repository,credentials in composer_http_basic.iteritems() %}
{% if loop.index0 %},{% endif %}
"{{ repository }}": {
"username": "{{ credentials.username }}",
"password": "{{ credentials.password }}"
}
{% endfor %}
}
{% endif %}
{% if composer_http_basic and composer_http_basic %},{% endif %}
{% if composer_github_oauth %}
"github-oauth": {
"github.com": "{{ composer_github_oauth }}"
}
{% endif %}
}
4 changes: 4 additions & 0 deletions tests/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
sudo: true
vars:
composer_github_oauth: f03401aae1e276abb073f987c08a32410f462e73
composer_http_basic:
repo.magento.com:
username: 52fe41da9d8caa70538244c10f367d0a
password: 238fe32d374a2573c4527bd45a7e6f54
roles:
- { role: common, tags: apt }
- { role: ../../ansible-role-composer, tags: composer }

0 comments on commit 1f1dd20

Please sign in to comment.