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

Composer Authentication: Add support for bearer, gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles #1413

Merged
merged 1 commit into from
Dec 4, 2022

Conversation

tangrufus
Copy link
Collaborator

@tangrufus tangrufus commented Jul 26, 2022

Add support for bearer gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles

Principle (type) Supported?
http-basic ✅ old feature
Inline http-basic ❌ use http-basic instead
HTTP Bearer (bearer)
Custom header ❌ composer doesn't support setting it in non-interactive mode
gitlab-oauth
gitlab-token
github-oauth
bitbucket-oauth

Breaking Changes

Note
Breaking changes have been removed. See: #1413 (comment)

This PR contains a breaking change. type is now required in composer_authentications.

For example:

---
composer_authentications:
  - { type: http-basic, hostname: http-basic.com, username: http-basic-username, password: http-basic-password }
  - { type: http-basic, hostname: second.http-basic.com/without-password, username:  second-http-basic-username }

  - { type: bearer, hostname: bearer.com, token: bearer-token }
  - { type: bearer, hostname: second.bearer.com/abc/def, token:  second-bearer-token }

  - { type: gitlab-oauth, hostname: gitlab.com, token: gitlab-com-oauth-token }
  - { type: gitlab-oauth, hostname: gitlab.oauth.org, token: gitlab-oauth-org-token }

  - { type: gitlab-token, hostname: gitlab.com, token: gitlab-com-token-token }
  - { type: gitlab-token, hostname: gitlab.token.org, token: gitlab-token-org-token }

  - { type: github-oauth, hostname: github.com, token: githubcomtoken }
  - { type: github-oauth, hostname: you.most.likely.set.this.to.github-com.example, token: youmostlikelysetthistogithubcomexampletoken }

  - { type: bitbucket-oauth, hostname: bitbucket.org, consumer_key: bitbucket-org-consumer-key, consumer_secret: bitbucket-org-consumer-secret }
  - { type: bitbucket-oauth, hostname: private-bitbucket.com, consumer_key: private-bitbucket-com-consumer-key, consumer_secret: private-bitbucket-com-consumer-secret }

The above example results in the following auth.json:

{
    "http-basic": {
        "http-basic.com": {
            "username": "http-basic-username",
            "password": "http-basic-password"
        },
        "second.http-basic.com/without-password": {
            "username": "second-http-basic-username",
            "password": ""
        }
    },
    "bitbucket-oauth": {
        "bitbucket.org": {
            "consumer-key": "bitbucket-org-consumer-key",
            "consumer-secret": "bitbucket-org-consumer-secret"
        },
        "private-bitbucket.com": {
            "consumer-key": "private-bitbucket-com-consumer-key",
            "consumer-secret": "private-bitbucket-com-consumer-secret"
        }
    },
    "bearer": {
        "bearer.com": "bearer-token",
        "second.bearer.com/abc/def": "second-bearer-token"
    },
    "gitlab-oauth": {
        "gitlab.com": "gitlab-com-oauth-token",
        "gitlab.oauth.org": "gitlab-oauth-org-token"
    },
    "gitlab-token": {
        "gitlab.com": "gitlab-com-token-token",
        "gitlab.token.org": "gitlab-token-org-token"
    },
    "github-oauth": {
        "github.com": "githubcomtoken",
        "you.most.likely.set.this.to.github-com.example": "youmostlikelysetthistogithubcomexampletoken"
    }
}

github-oauth was supported in v0.9.3 but removed in v0.9.6


See also:

@tangrufus tangrufus changed the title [BREAKING] Composer Authentication: Add support for bearer gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles [BREAKING] Composer Authentication: Add support for bearer, gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles Jul 26, 2022
…itlab-token`, `github-oauth` and `bitbucket-oauth` principles
@tangrufus tangrufus changed the title [BREAKING] Composer Authentication: Add support for bearer, gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles Composer Authentication: Add support for bearer, gitlab-oauth, gitlab-token, github-oauth and bitbucket-oauth principles Aug 26, 2022
@tangrufus
Copy link
Collaborator Author

tangrufus commented Aug 26, 2022

Defaults type to http-basic. No more breaking changes.

For example:

composer_authentications:
  - { hostname: default-type.com, username: default-type-username, password: default-type-password }
  - { hostname: second.default-type.com/without-password, username:  second-default-type-username }

  - { type: http-basic, hostname: http-basic.com, username: http-basic-username, password: http-basic-password }
  - { type: http-basic, hostname: second.http-basic.com/without-password, username:  second-http-basic-username }

  - { type: bearer, hostname: bearer.com, token: bearer-token }
  - { type: bearer, hostname: second.bearer.com/abc/def, token:  second-bearer-token }

  - { type: gitlab-oauth, hostname: gitlab.com, token: gitlab-com-oauth-token }
  - { type: gitlab-oauth, hostname: gitlab.oauth.org, token: gitlab-oauth-org-token }

  - { type: gitlab-token, hostname: gitlab.com, token: gitlab-com-token-token }
  - { type: gitlab-token, hostname: gitlab.token.org, token: gitlab-token-org-token }

  - { type: github-oauth, hostname: github.com, token: githubcomtoken }
  - { type: github-oauth, hostname: you.most.likely.set.this.to.github-com.example, token: youmostlikelysetthistogithubcomexampletoken }

  - { type: bitbucket-oauth, hostname: bitbucket.org, consumer_key: bitbucket-org-consumer-key, consumer_secret: bitbucket-org-consumer-secret }
  - { type: bitbucket-oauth, hostname: private-bitbucket.com, consumer_key: private-bitbucket-com-consumer-key, consumer_secret: private-bitbucket-com-consumer-secret }

The above example results in the following auth.json:

{
    "http-basic": {
        "default-type.com": {
            "username": "default-type-username",
            "password": "default-type-password"
        },
        "second.default-type.com/without-password": {
            "username": "second-default-type-username",
            "password": ""
        },
        "http-basic.com": {
            "username": "http-basic-username",
            "password": "http-basic-password"
        },
        "second.http-basic.com/without-password": {
            "username": "second-http-basic-username",
            "password": ""
        }
    },
    "bitbucket-oauth": {
        "bitbucket.org": {
            "consumer-key": "bitbucket-org-consumer-key",
            "consumer-secret": "bitbucket-org-consumer-secret"
        },
        "private-bitbucket.com": {
            "consumer-key": "private-bitbucket-com-consumer-key",
            "consumer-secret": "private-bitbucket-com-consumer-secret"
        }
    },
    "bearer": {
        "bearer.com": "bearer-token",
        "second.bearer.com/abc/def": "second-bearer-token"
    },
    "gitlab-oauth": {
        "gitlab.com": "gitlab-com-oauth-token",
        "gitlab.oauth.org": "gitlab-oauth-org-token"
    },
    "gitlab-token": {
        "gitlab.com": "gitlab-com-token-token",
        "gitlab.token.org": "gitlab-token-org-token"
    },
    "github-oauth": {
        "github.com": "githubcomtoken",
        "you.most.likely.set.this.to.github-com.example": "youmostlikelysetthistogithubcomexampletoken"
    }
}

Copy link
Member

@swalkinshaw swalkinshaw left a comment

Choose a reason for hiding this comment

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

Nice work 🚀

@tangrufus tangrufus merged commit 169ebc7 into roots:master Dec 4, 2022
@tangrufus tangrufus deleted the composer-auth-principles branch December 4, 2022 10:57
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.

2 participants