Updates to fix naming and layout

This commit is contained in:
Mark Wolfe 2020-01-07 09:02:18 +11:00
parent 438f07c664
commit 4a1d3a6521
No known key found for this signature in database
GPG Key ID: 4C6EDA7453BE9BE2
2 changed files with 17 additions and 15 deletions

View File

@ -18,7 +18,8 @@ var Amazon = oauth2.Endpoint{
} }
// Bitbucket provides endpoint for using OAuth2 to access Bitbucket. // Bitbucket provides endpoint for using OAuth2 to access Bitbucket.
var Bitbucket = oauth2.Endpoint{AuthURL: "https://bitbucket.org/site/oauth2/authorize", var Bitbucket = oauth2.Endpoint{
AuthURL: "https://bitbucket.org/site/oauth2/authorize",
TokenURL: "https://bitbucket.org/site/oauth2/access_token", TokenURL: "https://bitbucket.org/site/oauth2/access_token",
} }
@ -46,14 +47,14 @@ var Fitbit = oauth2.Endpoint{
TokenURL: "https://api.fitbit.com/oauth2/token", TokenURL: "https://api.fitbit.com/oauth2/token",
} }
// Github provides endpoint for using OAuth2 to access Github. // GitHub provides endpoint for using OAuth2 to access Github.
var Github = oauth2.Endpoint{ var GitHub = oauth2.Endpoint{
AuthURL: "https://github.com/login/oauth/authorize", AuthURL: "https://github.com/login/oauth/authorize",
TokenURL: "https://github.com/login/oauth/access_token", TokenURL: "https://github.com/login/oauth/access_token",
} }
// Gitlab provides endpoint for using OAuth2 to access Gitlab. // GitLab provides endpoint for using OAuth2 to access Gitlab.
var Gitlab = oauth2.Endpoint{ var GitLab = oauth2.Endpoint{
AuthURL: "https://gitlab.com/oauth/authorize", AuthURL: "https://gitlab.com/oauth/authorize",
TokenURL: "https://gitlab.com/oauth/token", TokenURL: "https://gitlab.com/oauth/token",
} }
@ -70,8 +71,9 @@ var Heroku = oauth2.Endpoint{
TokenURL: "https://id.heroku.com/oauth/token", TokenURL: "https://id.heroku.com/oauth/token",
} }
// Hipchat provides endpoint for using OAuth2 to access Hipchat. // HipChat provides endpoint for using OAuth2 to access HipChat.
var Hipchat = oauth2.Endpoint{AuthURL: "https://www.hipchat.com/users/authorize", var HipChat = oauth2.Endpoint{
AuthURL: "https://www.hipchat.com/users/authorize",
TokenURL: "https://api.hipchat.com/v2/oauth/token", TokenURL: "https://api.hipchat.com/v2/oauth/token",
} }
@ -105,8 +107,8 @@ var Mailru = oauth2.Endpoint{
TokenURL: "https://o2.mail.ru/token", TokenURL: "https://o2.mail.ru/token",
} }
// Mediamath provides endpoint for using OAuth2 to access Mediamath. // MediaMath provides endpoint for using OAuth2 to access MediaMath.
var Mediamath = oauth2.Endpoint{ var MediaMath = oauth2.Endpoint{
AuthURL: "https://api.mediamath.com/oauth2/v1.0/authorize", AuthURL: "https://api.mediamath.com/oauth2/v1.0/authorize",
TokenURL: "https://api.mediamath.com/oauth2/v1.0/token", TokenURL: "https://api.mediamath.com/oauth2/v1.0/token",
} }
@ -210,16 +212,16 @@ func AzureAD(tenant string) oauth2.Endpoint {
} }
} }
// HipchatServer returns a new oauth2.Endpoint for a HipChat Server instance // HipChatServer returns a new oauth2.Endpoint for a HipChat Server instance
// running on the given domain or host. // running on the given domain or host.
func HipchatServer(host string) oauth2.Endpoint { func HipChatServer(host string) oauth2.Endpoint {
return oauth2.Endpoint{ return oauth2.Endpoint{
AuthURL: "https://" + host + "/users/authorize", AuthURL: "https://" + host + "/users/authorize",
TokenURL: "https://" + host + "/v2/oauth/token", TokenURL: "https://" + host + "/v2/oauth/token",
} }
} }
// Cognito returns a new oauth2.Endpoint for the supplied AWS Cognito domain which is // AWSCognito returns a new oauth2.Endpoint for the supplied AWS Cognito domain which is
// linked to your Cognito User Pool. // linked to your Cognito User Pool.
// //
// Example domain: https://testing.auth.us-east-1.amazoncognito.com // Example domain: https://testing.auth.us-east-1.amazoncognito.com
@ -227,7 +229,7 @@ func HipchatServer(host string) oauth2.Endpoint {
// For more information see: // For more information see:
// https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-assign-domain.html // https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-assign-domain.html
// https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html // https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
func Cognito(domain string) oauth2.Endpoint { func AWSCognito(domain string) oauth2.Endpoint {
domain = strings.TrimRight(domain, "/") domain = strings.TrimRight(domain, "/")
return oauth2.Endpoint{ return oauth2.Endpoint{
AuthURL: domain + "/oauth2/authorize", AuthURL: domain + "/oauth2/authorize",

View File

@ -10,7 +10,7 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
) )
func TestCognitoEndpoint(t *testing.T) { func TestAWSCognitoEndpoint(t *testing.T) {
var endpointTests = []struct { var endpointTests = []struct {
in string in string
@ -34,7 +34,7 @@ func TestCognitoEndpoint(t *testing.T) {
for _, tt := range endpointTests { for _, tt := range endpointTests {
t.Run(tt.in, func(t *testing.T) { t.Run(tt.in, func(t *testing.T) {
endpoint := Cognito(tt.in) endpoint := AWSCognito(tt.in)
if endpoint != tt.out { if endpoint != tt.out {
t.Errorf("got %q, want %q", endpoint, tt.out) t.Errorf("got %q, want %q", endpoint, tt.out)
} }