Skip to content

Commit

Permalink
fix urls
Browse files Browse the repository at this point in the history
  • Loading branch information
lucjross committed Oct 11, 2019
1 parent e51c3c9 commit 6036867
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"github.com/markbates/goth/providers/apple"
"html/template"
"net/http"
"os"
Expand Down Expand Up @@ -124,6 +125,7 @@ func main() {
nextcloud.NewCustomisedDNS(os.Getenv("NEXTCLOUD_KEY"), os.Getenv("NEXTCLOUD_SECRET"), "http://localhost:3000/auth/nextcloud/callback", os.Getenv("NEXTCLOUD_URL")),
gitea.New(os.Getenv("GITEA_KEY"), os.Getenv("GITEA_SECRET"), "http://localhost:3000/auth/gitea/callback"),
shopify.New(os.Getenv("SHOPIFY_KEY"), os.Getenv("SHOPIFY_SECRET"), "http://localhost:3000/auth/shopify/callback", shopify.ScopeReadCustomers, shopify.ScopeReadOrders),
apple.New(os.Getenv("APPLE_KEY"), os.Getenv("APPLE_SECRET"), "http://localhost:3000/auth/apple/callback", nil),
)

// OpenID Connect is based on OpenID Connect Auto Discovery URL (https://openid.net/specs/openid-connect-discovery-1_0-17.html)
Expand Down Expand Up @@ -184,6 +186,7 @@ func main() {
m["naver"] = "Naver"
m["yandex"] = "Yandex"
m["nextcloud"] = "NextCloud"
m["apple"] = "Apple"

var keys []string
for k := range m {
Expand Down
8 changes: 4 additions & 4 deletions providers/apple/apple.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
)

const (
publicKeyFetchURL = "https://appleid.apple.com/auth/keys"
generateAndValidateTokensURL = "https://appleid.apple.com/auth/token"
authEndpoint = "https://appleid.apple.com/auth/authorize"
tokenEndpoint = "https://appleid.apple.com/auth/token"
)

type Provider struct {
Expand Down Expand Up @@ -101,8 +101,8 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
ClientSecret: provider.secret,
RedirectURL: provider.redirectURL,
Endpoint: oauth2.Endpoint{
AuthURL: generateAndValidateTokensURL,
TokenURL: publicKeyFetchURL,
AuthURL: authEndpoint,
TokenURL: tokenEndpoint,
},
Scopes: make([]string, 0, len(scopes)),
}
Expand Down
6 changes: 3 additions & 3 deletions providers/apple/apple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ func Test_BeginAuth(t *testing.T) {
session, err := p.BeginAuth("test_state")
s := session.(*Session)
a.NoError(err)
a.Contains(s.AuthURL, "appleid.apple.com/auth/token")
a.Contains(s.AuthURL, "appleid.apple.com/auth/authorize")
}

func Test_SessionFromJSON(t *testing.T) {
t.Parallel()
a := assert.New(t)

p := provider()
session, err := p.UnmarshalSession(`{"AuthURL":"https://appleid.apple.com/auth/token","AccessToken":"1234567890"}`)
session, err := p.UnmarshalSession(`{"AuthURL":"https://appleid.apple.com/auth/authorize","AccessToken":"1234567890"}`)
a.NoError(err)

s := session.(*Session)
a.Equal(s.AuthURL, "https://appleid.apple.com/auth/token")
a.Equal(s.AuthURL, "https://appleid.apple.com/auth/authorize")
a.Equal(s.AccessToken, "1234567890")
}

Expand Down

0 comments on commit 6036867

Please sign in to comment.