Repository navigation
Support third-party OAuth hosts - #7
Conversation
|
My original intention wasn't for this to be backwards-compatible, but looking back now its absolutely achievable - so I'll make an update to handle that.
No. GitHub's server implementation is non-standard and responds with I did make a start on this effort locally, with my original intent being to submit a second pr - those changes make sense under this pr, so I may just finish that up and push it here :) |
|
I will look at the tests in a bit, but I've verified that the changes now support Microsoft's endpoints :) Would you be interested in adding something like // ServerAzure gets a Server for the given Azure Active Directory tenant. If tenant is
// empty, it will default to "common".
//
// See https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code
func ServerAzure(tenant string) *Server {
if tenant == "" {
tenant = "common"
}
return &Server{
DeviceCodeURL: fmt.Sprintf("https://login.microsoftonline.com/%s/oauth2/v2.0/devicecode", tenant),
AuthorizeURL: fmt.Sprintf("https://login.microsoftonline.com/%s/oauth2/v2.0/authorize", tenant),
TokenURL: fmt.Sprintf("https://login.microsoftonline.com/%s/oauth2/v2.0/token", tenant),
}
} |
7d51c27 to
ec550ca
Compare
| "scope": "repo gist", | ||
| }, | ||
| }, | ||
| want: &AccessToken{ |
| values: make(map[string]string), | ||
| }, | ||
| wantErr: false, | ||
| }, |
| AuthorizeURL: fmt.Sprintf("https://%s/login/oauth/authorize", host), | ||
| TokenURL: fmt.Sprintf("https://%s/login/oauth/access_token", host), | ||
| } | ||
| } |
Not all OAuth hosts use the same routes as GitHub, for example: - Microsoft use /oauth2/v2.0/devicecode - Google use /device/code - Auth0 use /oauth/device/code Similar differences are present for the authorise and access token routes too. This commit introduces a concept of a Host, which is a container for the endpoints that the library uses. After this, the Hostname field is deprecated. Co-authored-by: Mislav Marohnić <[email protected]>
Co-authored-by: Mislav Marohnić <[email protected]>
mislav
left a comment
There was a problem hiding this comment.
Thanks for your patience! I've pushed some cleanups/renames.
Support third-party OAuth hosts Signed-off-by: antonio de jesus medina <[email protected]>
This pull request should make some headway to supporting further OAuth providers than just GitHub. This pull request doesn't introduce specific support for anything, but provides an API to allow third-parties to their flavour endpoints.
Not all OAuth hosts use the same routes as GitHub, for example:
Similar differences are present for the authorise and access token
routes too.
This commit introduces a concept of a Server, which is a container for
the endpoints that the library uses. This is a replacement for Flow's
Hostname and as such is a breaking change.