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

Add Yandex OAuth2 provider (#8335) #10564

Merged
merged 12 commits into from
Mar 4, 2020
1 change: 1 addition & 0 deletions models/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
ProfileURL: oauth2.GetDefaultProfileURL("nextcloud"),
},
},
"yandex": {Name: "yandex", DisplayName: "Yandex", Image: "/img/auth/yandex.png"},
}

// OAuth2DefaultCustomURLMappings contains the map of default URL's for OAuth2 providers that are allowed to have custom urls
Expand Down
4 changes: 4 additions & 0 deletions modules/auth/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/markbates/goth/providers/nextcloud"
"github.com/markbates/goth/providers/openidConnect"
"github.com/markbates/goth/providers/twitter"
"github.com/markbates/goth/providers/yandex"
"github.com/satori/go.uuid"
"xorm.io/xorm"
anatolym marked this conversation as resolved.
Show resolved Hide resolved
)
Expand Down Expand Up @@ -209,6 +210,9 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
}
}
provider = nextcloud.NewCustomisedURL(clientID, clientSecret, callbackURL, authURL, tokenURL, profileURL)
case "yandex":
// See https://tech.yandex.com/passport/doc/dg/reference/response-docpage/
provider = yandex.New(clientID, clientSecret, callbackURL, "login:email", "login:info", "login:avatar")
}

// always set the name if provider is created so we can support multiple setups of 1 provider
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,7 @@ auths.tip.openid_connect = Use the OpenID Connect Discovery URL (<server>/.well-
auths.tip.twitter = Go to https://dev.twitter.com/apps, create an application and ensure that the “Allow this application to be used to Sign in with Twitter” option is enabled
auths.tip.discord = Register a new application on https://discordapp.com/developers/applications/me
auths.tip.gitea = Register a new OAuth2 application. Guide can be found at https://docs.gitea.io/en-us/oauth2-provider/
auths.tip.yandex = Create a new application at https://oauth.yandex.com/client/new. Select following permissions from the "Yandex.Passport API" section: "Access to email address", "Access to user avatar" and "Access to username, first name and surname, gender"
auths.edit = Edit Authentication Source
auths.activated = This Authentication Source is Activated
auths.new_success = The authentication '%s' has been added.
Expand Down
Binary file added public/img/auth/yandex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions templates/admin/auth/new.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
<span>{{.i18n.Tr "admin.auths.tip.gitea"}}</span>
<li>Nextcloud</li>
<span>{{.i18n.Tr "admin.auths.tip.nextcloud"}}</span>
<li>Yandex</li>
<span>{{.i18n.Tr "admin.auths.tip.yandex"}}</span>
</div>
</div>
</div>
Expand Down
64 changes: 64 additions & 0 deletions vendor/github.com/markbates/goth/providers/yandex/session.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

183 changes: 183 additions & 0 deletions vendor/github.com/markbates/goth/providers/yandex/yandex.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ github.com/markbates/goth/providers/google
github.com/markbates/goth/providers/nextcloud
github.com/markbates/goth/providers/openidConnect
github.com/markbates/goth/providers/twitter
github.com/markbates/goth/providers/yandex
# github.com/mattn/go-isatty v0.0.7
github.com/mattn/go-isatty
# github.com/mattn/go-sqlite3 v1.11.0
Expand Down