Граф коммитов

52 Коммитов

Автор SHA1 Сообщение Дата
Mislav Marohnić a6389b3a81 Print token authorization URL on HTTP 403 due to `X-Github-Sso` challenge 2020-01-19 14:58:49 +01:00
Phil Dibowitz 1e35be83c1 Make a gist command
This addresses #2226 and #2116 by creating a `gist` subcommand.

This allows you to both create and retrieve gists. When creating a gist
it can be public or private.

In order to do this, the `gist` scope is added to the token we request.

Closes: #2226
Closes: #2116

Signed-off-by: Phil Dibowitz <phil@ipom.com>
2019-09-16 23:55:58 -07:00
Mislav Marohnić c9dac78bb7 [auth] Infer GITHUB_USER value from GITHUB_REPOSITORY
This allows hub to be easier used within GitHub Actions where GITHUB_REPOSITORY is pre-populated by default. If GITHUB_USER is not set in the environment, its value is inferred from the part of GITHUB_REPOSITORY value until the first slash character.
2019-09-03 16:43:08 -07:00
Mislav Marohnić 09285c4872 Fix matching variable output such as `$HOME` for new Aruba 2019-08-21 18:22:48 +02:00
Mislav Marohnić 11c6418747 Misc. Aruba compatibility 2019-08-21 17:29:00 +02:00
Mislav Marohnić 2aef00312c [auth] Allow hub used in Actions by specifying GITHUB_USER
When supplied with GITHUB_TOKEN, hub will attempt to request the `user`
API resource which isn't available in the context of Actions.

To work around this, scripts may now set GITHUB_USER to avoid hitting
the unavailable API resource.
2019-07-19 14:12:08 +02:00
Mislav Marohnić 954c3c3432 [auth] Show friendlier error message when fetching current user fails
Hub is impossible to use from within GitHub Actions because specifying
GITHUB_TOKEN will trigger the code path where the `user` resource is
requested from the GitHub API to get the current login name, but this
resource is not available for that token.

This failure message was cryptic and misleading before as it was
sometimes presented as HTTP 401. This change ensures that the correct
HTTP 403 "Resource not accessible by integration" message is shown.
2019-07-19 14:11:08 +02:00
Mislav Marohnić be76a9f80f Fix test broken by OAuth URL update 2018-11-28 03:20:10 +01:00
Mislav Marohnić d3ac6c474b Fix `hub create` in place of a renamed repo
If you're trying to create `owner/foo` repo and there is an existing
redirect from `owner/foo` to a differently name repo, don't consider
that one as an existing repo and proceed with creating `owner/foo`.
2018-08-31 13:00:04 +02:00
Mislav Marohnić f8bd902145 Support XDG Base Directory Specification
Respect XDG_CONFIG_HOME and XDG_CONFIG_DIRS.
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

Fixes #1048, closes #1061
2018-06-07 19:57:02 +02:00
Mislav Marohnić 02db852769 Remove outdated token-as-password test
Full tokens (40 characters) are now allowed as password and tested in a
separate scenario.
2018-06-07 19:22:46 +02:00
Bill Mill 5f9b034b44 Allow user to provide a token instead of a password 2018-05-18 14:49:51 +02:00
Mislav Marohnić ba01855cc2 Authenticate with GitHub API without octokit 2018-01-29 20:59:23 +01:00
Mislav Marohnić 04fa2016fc Create a repository without octokit 2018-01-29 20:59:23 +01:00
Mislav Marohnić de6a2bd58d Fetch repository information without octokit 2018-01-29 20:59:22 +01:00
Goel 0d672939de Move checkWriteable to config.
If file is not present before checking for writing, remove it after check.
Add test to check for writeability in default location
2016-10-31 17:01:32 +05:30
Goel b88906b61d Check if config location is writeable before authenticating
Fixes #1314
2016-10-30 21:53:05 +05:30
Mislav Marohnić 193d8f8620 Follow 307 redirects in `fork`
Also, adopt the new name of the fork more precisely so it's reflected in
the new remote URL. The name of the new git remote is for now *not*
inherited from the returned Repository object for backwards compatibility.

Fixes #1178
2016-08-09 22:07:33 +02:00
Pascal Corpet c53dbe4239 Prompt for user when the config has a token but no user. Fixes #1007 2016-02-15 14:51:11 +01:00
Mislav Marohnić 1c6d4b8cf5 Make GITHUB_TOKEN have precedence over auth info from config 2015-09-26 10:41:53 +02:00
Parker Moore 27f2023e80 config: if GITHUB_TOKEN is set, do not attempt to create one
Fixes #463 and #948
2015-07-28 17:03:25 -07:00
Jingwen Owen Ou 2aed42f7bd Fix enterprise authentication cuke and move it to authentication.feature 2014-12-24 15:50:41 -08:00
Mislav Marohnić f94c31cc0f Add cukes from https://github.com/github/hub/pull/738 2014-12-24 09:10:21 -08:00
Jingwen Owen Ou 72d8220279 Revert cukes to test yaml config 2014-09-16 09:59:42 -07:00
Jingwen Owen Ou f1657b0bb2 Paginate API authorizations when searching for existing hub token 2014-07-25 15:53:37 -07:00
Jingwen Owen Ou 04677d39f4 Merge remote-tracking branch 'origin/master' into merge_master
Conflicts:
	features/pull_request.feature
2014-06-09 07:38:09 -07:00
Mislav Marohnić ff5a17759a Fix API 422 error: `Duplicate value for "description"`
When looking up an existing hub token among user's authorizations, be
sure to fetch all results by following pagination links. Previously we
just stopped at the 1st page, and if the token for hub didn't appear
there we would try to create it, which would result in a 422 validation
error if it already existed.

References 1e4477b566

Fixes #531, fixes #558, fixes #563
2014-05-16 01:17:21 +07:00
Jingwen Owen Ou df804767c6 Update to use note and note_url for auth 2014-04-12 00:08:48 -07:00
Mislav Marohnić 24add1e38a Merge remote-tracking branch 'origin/master' into master-to-gh 2014-04-11 18:05:59 +02:00
Jingwen Owen Ou b8a64ac93a Make X-GitHub-OTP exactly as what the API server returns 2014-03-24 15:47:03 -07:00
Jingwen Owen Ou a01fea2a15 Make sure special characters work in cukes 2014-03-13 11:47:36 -07:00
Jingwen Owen Ou 9cc2023a7b More fixing of the right X-GitHub-OTP header 2014-03-13 11:42:11 -07:00
Jingwen Owen Ou d38fd5f14b Use the right format for X-GitHub-OTP in dukes
See ab0404e0f1/lib/octokit/error.rb (L155)
2014-03-13 11:35:30 -07:00
Jingwen Owen Ou 212b0b18f5 Change expectation from oauth_token to access_token 2014-03-13 11:08:31 -07:00
Jingwen Owen Ou fb1bda9a87 Fix OAuthAppURL 2014-03-13 11:05:48 -07:00
Jingwen Owen Ou 026ac1602c Use current user's login for config user name 2014-03-13 10:28:01 -07:00
Mislav Marohnić 1e4477b566 Fix reusing old OAuth tokens stored in Authorizations API
For people who are using hub for a longer time now, hub has stored an OAuth
token in Authorizations API with a `note_url` value that is now outdated
(e.g. "http://defunkt.io/hub/"). The newer `oauth_app_url` doesn't match
that, so the token is not reused. Hub tries to create a new OAuth token
with a `note` that says "hub" which fails with a 422 because it already
exists.

This fixes reusing old OAuth tokens even if the `note_url` doesn't match
anymore. Any key with `note` that says "hub" will get reused.

Fixes #496
2014-02-28 16:26:25 +01:00
Mislav Marohnić 0f44f3e328 Respect `note_url`, not `app.url` field in Authorizations API
Technically, they're going to be the same values for OAuth tokens
created via the API, but since we write to `note_url` field it makes
sense to use the same field to read the value back, for consistency.
2014-02-28 16:26:25 +01:00
Mislav Marohnić e70f7ba847 Fix 2FA for users that receive code via SMS
hub initially tries to fetch user's existing OAuth token for hub if it
exists, and will prompt the user for a 2FA code. However those who
receive it via SMS would never get the code since a GET to GitHub's
Authorizations API purposely doesn't trigger an SMS. There's some
discussion as to whether this is an API bug for not, but in the
meantime, make a dummy POST request for the sole reason of triggering
the SMS.

Fixes #412, closes #435, closes #445
2013-12-19 17:01:44 +01:00
Mislav Marohnić f52c0a5061 Rewrite API auth to allow Enterprise email login
API authentication and persisting of credentials in Config was
convoluted and inflexible, and it wasn't possible to log in with
different credentials than your GitHub screen name. Since Enterprise
supports different authentication schemes, it's important to allow
emails for login as well (or any string for that matter) and retrieve
the user's screen name after successful authentication.

This also improves handling special characters in Basic Auth usernames
and passwords.

Fixes #407
2013-12-19 17:01:44 +01:00
Yasuharu Ozaki f45c1e0ea3 fix two factor authentication when creating a new token
Enable to create a new OAuth token even when user enabled two factor
authentication.

References #399
2013-10-01 21:15:31 +02:00
Mislav Marohnić 1412e509cb add test for special characters during authentication
references #407
2013-09-30 07:25:36 +02:00
Mislav Marohnić 5649867da9 enable two-factor authentication
fixes #399

http://developer.github.com/v3/auth/#working-with-two-factor-authentication
2013-09-19 18:31:03 -04:00
Mislav Marohnić aeeb1e6a6e do the dance one more time 2013-07-13 03:33:04 +02:00
Mislav Marohnić 9b1f16d393 awww yeah 🔥 2013-07-09 22:32:00 +02:00
Mislav Marohnić 99c51069fa simplify assertion of supplied API params 2013-05-12 21:11:42 +02:00
Mislav Marohnić bc361d0c5a persist correctly capitalized login name for the user
Fixes #263
2012-11-24 20:22:22 +01:00
Mislav Marohnić d91214c4e0 `create` command uses API response to assign remote URL
This ensures we end up with the correct capitalization of user's login
name, and gives the opportunity to the server to change the project name
without having us choke on it.

Fixes #263
2012-11-22 13:27:01 +01:00
Mislav Marohnić 50e3626157 respect $GITHUB_USER & $GITHUB_PASSWORD
Fixes #245
2012-11-05 21:45:46 +01:00
Mislav Marohnić 7ab0d27ffa abandon the nasty JSON hack for Sinatra responses
I tried to hack Sinatra to automatically serialize non-string response
bodies as JSON, but this is not straightforward due to sinatra/sinatra#512
and doesn't really work in a whole lot of edge-cases.

Introduced a simple `json` helper and now using that instead of `body`.
2012-10-10 13:50:23 +02:00