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
Next Next commit
OAuth2: add Yandex provider (#8335)
  • Loading branch information
anatolym committed Mar 2, 2020
commit cfd7516f77e68bddcddf0da7bec4bc49ceadc9bb
1 change: 1 addition & 0 deletions models/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var OAuth2Providers = map[string]OAuth2Provider{
ProfileURL: oauth2.GetDefaultProfileURL("gitea"),
},
},
"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
6 changes: 5 additions & 1 deletion modules/auth/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
"github.com/markbates/goth/providers/google"
"github.com/markbates/goth/providers/openidConnect"
"github.com/markbates/goth/providers/twitter"
"github.com/satori/go.uuid"
"github.com/markbates/goth/providers/yandex"
uuid "github.com/satori/go.uuid"
"xorm.io/xorm"
anatolym marked this conversation as resolved.
Show resolved Hide resolved
)

Expand Down Expand Up @@ -192,6 +193,9 @@ func createProvider(providerName, providerType, clientID, clientSecret, openIDCo
}
}
provider = gitea.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 @@ -1917,6 +1917,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
3 changes: 2 additions & 1 deletion options/locale/locale_ru-RU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,8 @@ auths.tip.google_plus=Получите учетные данные клиент
auths.tip.openid_connect=Используйте OpenID Connect Discovery URL (<server>/.well-known/openid-configuration) для автоматической настройки входа OAuth
auths.tip.twitter=Перейдите на https://dev.twitter.com/apps, создайте приложение и убедитесь, что включена опция «Разрешить это приложение для входа в систему с помощью Twitter»
auths.tip.discord=Добавьте новое приложение на https://discordapp.com/developers/applications/me
auths.tip.gitea=Зарегистрировать новое приложение OAuth2. Руководство можно найти на https://docs.gitea.io/ru-us/oauth2-provider/
auths.tip.gitea=Зарегистрируйте новое приложение OAuth2. Руководство можно найти на https://docs.gitea.io/ru-us/oauth2-provider/
guillep2k marked this conversation as resolved.
Show resolved Hide resolved
auths.tip.yandex=Зарегистрируйте новое приложение https://oauth.yandex.ru/client/new. Добавьте разрешения в группе "API Яндекс.Паспорта": "Доступ к адресу электронной почты", "Доступ к логину, имени и фамилии, полу" and "Доступ к портрету пользователя"
auths.edit=Обновить параметры аутентификации
auths.activated=Эта аутентификация активирована
auths.new_success=Метод аутентификации '%s' был добавлен.
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 @@ -115,6 +115,8 @@
<span>{{.i18n.Tr "admin.auths.tip.discord"}}</span>
<li>Gitea</li>
<span>{{.i18n.Tr "admin.auths.tip.gitea"}}</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 @@ -313,6 +313,7 @@ github.com/markbates/goth/providers/gitlab
github.com/markbates/goth/providers/google
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