Skip to content

Commit 3d5d211

Browse files
lafrikslunny6543guillep2ktechknowlogick
authored
OAuth2: add Yandex provider (#8335) (#10564)
* OAuth2: add Yandex provider (#8335) * remove changes from locale ru-RU * fmt modules/auth/oauth2/oauth2.go Co-Authored-By: 6543 <[email protected]> * fix fmt * Update templates/admin/auth/new.tmpl * fix fmt Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: guillep2k <[email protected]> Co-authored-by: techknowlogick <[email protected]> Co-authored-by: Lauris BH <[email protected]>
1 parent afa1e1a commit 3d5d211

File tree

8 files changed

+256
-0
lines changed

8 files changed

+256
-0
lines changed

models/oauth2.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
5858
ProfileURL: oauth2.GetDefaultProfileURL("nextcloud"),
5959
},
6060
},
61+
"yandex": {Name: "yandex", DisplayName: "Yandex", Image: "/img/auth/yandex.png"},
6162
}
6263

6364
// OAuth2DefaultCustomURLMappings contains the map of default URL's for OAuth2 providers that are allowed to have custom urls

modules/auth/oauth2/oauth2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/markbates/goth/providers/nextcloud"
2626
"github.com/markbates/goth/providers/openidConnect"
2727
"github.com/markbates/goth/providers/twitter"
28+
"github.com/markbates/goth/providers/yandex"
2829
"github.com/satori/go.uuid"
2930
"xorm.io/xorm"
3031
)
@@ -209,6 +210,9 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
209210
}
210211
}
211212
provider = nextcloud.NewCustomisedURL(clientID, clientSecret, callbackURL, authURL, tokenURL, profileURL)
213+
case "yandex":
214+
// See https://tech.yandex.com/passport/doc/dg/reference/response-docpage/
215+
provider = yandex.New(clientID, clientSecret, callbackURL, "login:email", "login:info", "login:avatar")
212216
}
213217

214218
// always set the name if provider is created so we can support multiple setups of 1 provider

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,7 @@ auths.tip.openid_connect = Use the OpenID Connect Discovery URL (<server>/.well-
19371937
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
19381938
auths.tip.discord = Register a new application on https://discordapp.com/developers/applications/me
19391939
auths.tip.gitea = Register a new OAuth2 application. Guide can be found at https://docs.gitea.io/en-us/oauth2-provider/
1940+
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"
19401941
auths.edit = Edit Authentication Source
19411942
auths.activated = This Authentication Source is Activated
19421943
auths.new_success = The authentication '%s' has been added.

public/img/auth/yandex.png

826 Bytes
Loading

templates/admin/auth/new.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
<span>{{.i18n.Tr "admin.auths.tip.gitea"}}</span>
118118
<li>Nextcloud</li>
119119
<span>{{.i18n.Tr "admin.auths.tip.nextcloud"}}</span>
120+
<li>Yandex</li>
121+
<span>{{.i18n.Tr "admin.auths.tip.yandex"}}</span>
120122
</div>
121123
</div>
122124
</div>

vendor/github.com/markbates/goth/providers/yandex/session.go

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/markbates/goth/providers/yandex/yandex.go

Lines changed: 183 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ github.com/markbates/goth/providers/google
314314
github.com/markbates/goth/providers/nextcloud
315315
github.com/markbates/goth/providers/openidConnect
316316
github.com/markbates/goth/providers/twitter
317+
github.com/markbates/goth/providers/yandex
317318
# github.com/mattn/go-isatty v0.0.7
318319
github.com/mattn/go-isatty
319320
# github.com/mattn/go-sqlite3 v1.11.0

0 commit comments

Comments
 (0)