Compare commits

...

6 Commits

Author SHA1 Message Date
543b316942 feat: update swagger parameter id description (#1532) 2023-02-10 10:42:16 +08:00
e2b6e8ee6e chore: unify migrate database way (#1530) 2023-02-09 19:28:15 +08:00
wht
e7e0518517 feat: fix the upload file name contains space problem (#1527) 2023-02-07 23:26:17 +08:00
943aa61869 feat: add provider icons and menus (#1522)
* fix: add provider icons(email and captcha) and menus

* fix: add provider icons and menus
2023-02-06 20:28:40 +08:00
wht
fcc75dd3be feat: fix the Unicode filename encoding bug in storage provider (#1518) 2023-02-04 18:09:18 +08:00
8698f4111a feat: add all remaining Goth providers to Casdoor OAuth login (#1484)
* feat: add Amazon support as OAuth 3rd-party login

* refactor: comebine the same URLs

* refactor: use hyper component to create login button

* feat: add all remaining Goth providers to Casdoor OAuth login

* refactor: remove redundant props

* fix: check provider auth url and params
2023-02-04 12:20:18 +08:00
33 changed files with 1129 additions and 254 deletions

View File

@ -63,7 +63,7 @@ func (c *ApiController) GetApplications() {
// @Title GetApplication
// @Tag Application API
// @Description get the detail of an application
// @Param id query string true "The id of the application."
// @Param id query string true "The id ( owner/name ) of the application."
// @Success 200 {object} object.Application The Response object
// @router /get-application [get]
func (c *ApiController) GetApplication() {
@ -78,7 +78,7 @@ func (c *ApiController) GetApplication() {
// @Title GetUserApplication
// @Tag Application API
// @Description get the detail of the user's application
// @Param id query string true "The id of the user"
// @Param id query string true "The id ( owner/name ) of the user"
// @Success 200 {object} object.Application The Response object
// @router /get-user-application [get]
func (c *ApiController) GetUserApplication() {
@ -134,7 +134,7 @@ func (c *ApiController) GetOrganizationApplications() {
// @Title UpdateApplication
// @Tag Application API
// @Description update an application
// @Param id query string true "The id of the application"
// @Param id query string true "The id ( owner/name ) of the application"
// @Param body body object.Application true "The details of the application"
// @Success 200 {object} controllers.Response The Response object
// @router /update-application [post]

View File

@ -174,13 +174,36 @@ func (c *ApiController) GetApplicationLogin() {
}
func setHttpClient(idProvider idp.IdProvider, providerType string) {
if providerType == "GitHub" || providerType == "Google" || providerType == "Facebook" || providerType == "LinkedIn" || providerType == "Steam" || providerType == "Line" {
if isProxyProviderType(providerType) {
idProvider.SetHttpClient(proxy.ProxyHttpClient)
} else {
idProvider.SetHttpClient(proxy.DefaultHttpClient)
}
}
func isProxyProviderType(providerType string) bool {
providerTypes := []string{
"GitHub",
"Google",
"Facebook",
"LinkedIn",
"Steam",
"Line",
"Amazon",
"Instagram",
"TikTok",
"Twitter",
"Uber",
"Yahoo",
}
for _, v := range providerTypes {
if strings.EqualFold(v, providerType) {
return true
}
}
return false
}
// Login ...
// @Title Login
// @Tag Login API

View File

@ -52,7 +52,7 @@ func (c *ApiController) GetCerts() {
// @Title GetCert
// @Tag Cert API
// @Description get cert
// @Param id query string true "The id of the cert"
// @Param id query string true "The id ( owner/name ) of the cert"
// @Success 200 {object} object.Cert The Response object
// @router /get-cert [get]
func (c *ApiController) GetCert() {
@ -66,7 +66,7 @@ func (c *ApiController) GetCert() {
// @Title UpdateCert
// @Tag Cert API
// @Description update cert
// @Param id query string true "The id of the cert"
// @Param id query string true "The id ( owner/name ) of the cert"
// @Param body body object.Cert true "The details of the cert"
// @Success 200 {object} controllers.Response The Response object
// @router /update-cert [post]

View File

@ -52,7 +52,7 @@ func (c *ApiController) GetModels() {
// @Title GetModel
// @Tag Model API
// @Description get model
// @Param id query string true "The id of the model"
// @Param id query string true "The id ( owner/name ) of the model"
// @Success 200 {object} object.Model The Response object
// @router /get-model [get]
func (c *ApiController) GetModel() {
@ -66,7 +66,7 @@ func (c *ApiController) GetModel() {
// @Title UpdateModel
// @Tag Model API
// @Description update model
// @Param id query string true "The id of the model"
// @Param id query string true "The id ( owner/name ) of the model"
// @Param body body object.Model true "The details of the model"
// @Success 200 {object} controllers.Response The Response object
// @router /update-model [post]

View File

@ -66,7 +66,7 @@ func (c *ApiController) GetOrganization() {
// @Title UpdateOrganization
// @Tag Organization API
// @Description update organization
// @Param id query string true "The id of the organization"
// @Param id query string true "The id ( owner/name ) of the organization"
// @Param body body object.Organization true "The details of the organization"
// @Success 200 {object} controllers.Response The Response object
// @router /update-organization [post]

View File

@ -71,7 +71,7 @@ func (c *ApiController) GetUserPayments() {
// @Title GetPayment
// @Tag Payment API
// @Description get payment
// @Param id query string true "The id of the payment"
// @Param id query string true "The id ( owner/name ) of the payment"
// @Success 200 {object} object.Payment The Response object
// @router /get-payment [get]
func (c *ApiController) GetPayment() {
@ -85,7 +85,7 @@ func (c *ApiController) GetPayment() {
// @Title UpdatePayment
// @Tag Payment API
// @Description update payment
// @Param id query string true "The id of the payment"
// @Param id query string true "The id ( owner/name ) of the payment"
// @Param body body object.Payment true "The details of the payment"
// @Success 200 {object} controllers.Response The Response object
// @router /update-payment [post]
@ -172,7 +172,7 @@ func (c *ApiController) NotifyPayment() {
// @Title InvoicePayment
// @Tag Payment API
// @Description invoice payment
// @Param id query string true "The id of the payment"
// @Param id query string true "The id ( owner/name ) of the payment"
// @Success 200 {object} controllers.Response The Response object
// @router /invoice-payment [post]
func (c *ApiController) InvoicePayment() {

View File

@ -69,7 +69,7 @@ func (c *ApiController) GetPermissionsBySubmitter() {
// @Title GetPermissionsByRole
// @Tag Permission API
// @Description get permissions by role
// @Param id query string true "The id of the role"
// @Param id query string true "The id ( owner/name ) of the role"
// @Success 200 {array} object.Permission The Response object
// @router /get-permissions-by-role [get]
func (c *ApiController) GetPermissionsByRole() {
@ -83,7 +83,7 @@ func (c *ApiController) GetPermissionsByRole() {
// @Title GetPermission
// @Tag Permission API
// @Description get permission
// @Param id query string true "The id of the permission"
// @Param id query string true "The id ( owner/name ) of the permission"
// @Success 200 {object} object.Permission The Response object
// @router /get-permission [get]
func (c *ApiController) GetPermission() {
@ -97,7 +97,7 @@ func (c *ApiController) GetPermission() {
// @Title UpdatePermission
// @Tag Permission API
// @Description update permission
// @Param id query string true "The id of the permission"
// @Param id query string true "The id ( owner/name ) of the permission"
// @Param body body object.Permission true "The details of the permission"
// @Success 200 {object} controllers.Response The Response object
// @router /update-permission [post]

View File

@ -53,7 +53,7 @@ func (c *ApiController) GetProducts() {
// @Title GetProduct
// @Tag Product API
// @Description get product
// @Param id query string true "The id of the product"
// @Param id query string true "The id ( owner/name ) of the product"
// @Success 200 {object} object.Product The Response object
// @router /get-product [get]
func (c *ApiController) GetProduct() {
@ -70,7 +70,7 @@ func (c *ApiController) GetProduct() {
// @Title UpdateProduct
// @Tag Product API
// @Description update product
// @Param id query string true "The id of the product"
// @Param id query string true "The id ( owner/name ) of the product"
// @Param body body object.Product true "The details of the product"
// @Success 200 {object} controllers.Response The Response object
// @router /update-product [post]
@ -130,7 +130,7 @@ func (c *ApiController) DeleteProduct() {
// @Title BuyProduct
// @Tag Product API
// @Description buy product
// @Param id query string true "The id of the product"
// @Param id query string true "The id ( owner/name ) of the product"
// @Param providerName query string true "The name of the provider"
// @Success 200 {object} controllers.Response The Response object
// @router /buy-product [post]

View File

@ -76,7 +76,7 @@ func (c *ApiController) GetGlobalProviders() {
// @Title GetProvider
// @Tag Provider API
// @Description get provider
// @Param id query string true "The id of the provider"
// @Param id query string true "The id ( owner/name ) of the provider"
// @Success 200 {object} object.Provider The Response object
// @router /get-provider [get]
func (c *ApiController) GetProvider() {
@ -89,7 +89,7 @@ func (c *ApiController) GetProvider() {
// @Title UpdateProvider
// @Tag Provider API
// @Description update provider
// @Param id query string true "The id of the provider"
// @Param id query string true "The id ( owner/name ) of the provider"
// @Param body body object.Provider true "The details of the provider"
// @Success 200 {object} controllers.Response The Response object
// @router /update-provider [post]

View File

@ -52,7 +52,7 @@ func (c *ApiController) GetRoles() {
// @Title GetRole
// @Tag Role API
// @Description get role
// @Param id query string true "The id of the role"
// @Param id query string true "The id ( owner/name ) of the role"
// @Success 200 {object} object.Role The Response object
// @router /get-role [get]
func (c *ApiController) GetRole() {
@ -66,7 +66,7 @@ func (c *ApiController) GetRole() {
// @Title UpdateRole
// @Tag Role API
// @Description update role
// @Param id query string true "The id of the role"
// @Param id query string true "The id ( owner/name ) of the role"
// @Param body body object.Role true "The details of the role"
// @Success 200 {object} controllers.Response The Response object
// @router /update-role [post]

View File

@ -26,7 +26,7 @@ import (
// @Title DeleteSession
// @Tag Session API
// @Description Delete session by userId
// @Param ID query string true "The ID(owner/name) of user."
// @Param id query string true "The id ( owner/name )(owner/name) of user."
// @Success 200 {array} string The Response object
// @router /delete-session [post]
func (c *ApiController) DeleteSession() {

View File

@ -52,7 +52,7 @@ func (c *ApiController) GetSyncers() {
// @Title GetSyncer
// @Tag Syncer API
// @Description get syncer
// @Param id query string true "The id of the syncer"
// @Param id query string true "The id ( owner/name ) of the syncer"
// @Success 200 {object} object.Syncer The Response object
// @router /get-syncer [get]
func (c *ApiController) GetSyncer() {
@ -66,7 +66,7 @@ func (c *ApiController) GetSyncer() {
// @Title UpdateSyncer
// @Tag Syncer API
// @Description update syncer
// @Param id query string true "The id of the syncer"
// @Param id query string true "The id ( owner/name ) of the syncer"
// @Param body body object.Syncer true "The details of the syncer"
// @Success 200 {object} controllers.Response The Response object
// @router /update-syncer [post]

View File

@ -29,7 +29,7 @@ type SystemInfo struct {
// @Title GetSystemInfo
// @Tag System API
// @Description get user's system info
// @Param id query string true "The id of the user"
// @Param id query string true "The id ( owner/name ) of the user"
// @Success 200 {object} object.SystemInfo The Response object
// @router /get-system-info [get]
func (c *ApiController) GetSystemInfo() {

View File

@ -54,7 +54,7 @@ func (c *ApiController) GetTokens() {
// @Title GetToken
// @Tag Token API
// @Description get token
// @Param id query string true "The id of token"
// @Param id query string true "The id ( owner/name ) of token"
// @Success 200 {object} object.Token The Response object
// @router /get-token [get]
func (c *ApiController) GetToken() {
@ -68,7 +68,7 @@ func (c *ApiController) GetToken() {
// @Title UpdateToken
// @Tag Token API
// @Description update token
// @Param id query string true "The id of token"
// @Param id query string true "The id ( owner/name ) of token"
// @Param body body object.Token true "Details of the token"
// @Success 200 {object} controllers.Response The Response object
// @router /update-token [post]
@ -128,7 +128,7 @@ func (c *ApiController) DeleteToken() {
// @Title GetOAuthCode
// @Tag Token API
// @Description get OAuth code
// @Param user_id query string true "The id of user"
// @Param id query string true "The id ( owner/name ) of user"
// @Param client_id query string true "OAuth client id"
// @Param response_type query string true "OAuth response type"
// @Param redirect_uri query string true "OAuth redirect URI"

View File

@ -80,7 +80,7 @@ func (c *ApiController) GetUsers() {
// @Title GetUser
// @Tag User API
// @Description get user
// @Param id query string true "The id of the user"
// @Param id query string true "The id ( owner/name ) of the user"
// @Param owner query string false "The owner of the user"
// @Param email query string false "The email of the user"
// @Param phone query string false "The phone of the user"
@ -129,7 +129,7 @@ func (c *ApiController) GetUser() {
// @Title UpdateUser
// @Tag User API
// @Description update user
// @Param id query string true "The id of the user"
// @Param id query string true "The id ( owner/name ) of the user"
// @Param body body object.User true "The details of the user"
// @Success 200 {object} controllers.Response The Response object
// @router /update-user [post]

View File

@ -52,7 +52,7 @@ func (c *ApiController) GetWebhooks() {
// @Title GetWebhook
// @Tag Webhook API
// @Description get webhook
// @Param id query string true "The id of the webhook"
// @Param id query string true "The id ( owner/name ) of the webhook"
// @Success 200 {object} object.Webhook The Response object
// @router /get-webhook [get]
func (c *ApiController) GetWebhook() {
@ -66,7 +66,7 @@ func (c *ApiController) GetWebhook() {
// @Title UpdateWebhook
// @Tag Webhook API
// @Description update webhook
// @Param id query string true "The id of the webhook"
// @Param id query string true "The id ( owner/name ) of the webhook"
// @Param body body object.Webhook true "The details of the webhook"
// @Success 200 {object} controllers.Response The Response object
// @router /update-webhook [post]

View File

@ -25,30 +25,59 @@ import (
"github.com/markbates/goth"
"github.com/markbates/goth/providers/amazon"
"github.com/markbates/goth/providers/apple"
"github.com/markbates/goth/providers/auth0"
"github.com/markbates/goth/providers/azureadv2"
"github.com/markbates/goth/providers/battlenet"
"github.com/markbates/goth/providers/bitbucket"
"github.com/markbates/goth/providers/box"
"github.com/markbates/goth/providers/cloudfoundry"
"github.com/markbates/goth/providers/dailymotion"
"github.com/markbates/goth/providers/deezer"
"github.com/markbates/goth/providers/digitalocean"
"github.com/markbates/goth/providers/discord"
"github.com/markbates/goth/providers/dropbox"
"github.com/markbates/goth/providers/eveonline"
"github.com/markbates/goth/providers/facebook"
"github.com/markbates/goth/providers/fitbit"
"github.com/markbates/goth/providers/gitea"
"github.com/markbates/goth/providers/github"
"github.com/markbates/goth/providers/gitlab"
"github.com/markbates/goth/providers/google"
"github.com/markbates/goth/providers/heroku"
"github.com/markbates/goth/providers/influxcloud"
"github.com/markbates/goth/providers/instagram"
"github.com/markbates/goth/providers/intercom"
"github.com/markbates/goth/providers/kakao"
"github.com/markbates/goth/providers/lastfm"
"github.com/markbates/goth/providers/line"
"github.com/markbates/goth/providers/linkedin"
"github.com/markbates/goth/providers/mailru"
"github.com/markbates/goth/providers/meetup"
"github.com/markbates/goth/providers/microsoftonline"
"github.com/markbates/goth/providers/naver"
"github.com/markbates/goth/providers/nextcloud"
"github.com/markbates/goth/providers/onedrive"
"github.com/markbates/goth/providers/oura"
"github.com/markbates/goth/providers/patreon"
"github.com/markbates/goth/providers/paypal"
"github.com/markbates/goth/providers/salesforce"
"github.com/markbates/goth/providers/shopify"
"github.com/markbates/goth/providers/slack"
"github.com/markbates/goth/providers/soundcloud"
"github.com/markbates/goth/providers/spotify"
"github.com/markbates/goth/providers/steam"
"github.com/markbates/goth/providers/strava"
"github.com/markbates/goth/providers/stripe"
"github.com/markbates/goth/providers/tiktok"
"github.com/markbates/goth/providers/tumblr"
"github.com/markbates/goth/providers/twitter"
"github.com/markbates/goth/providers/twitch"
"github.com/markbates/goth/providers/twitterv2"
"github.com/markbates/goth/providers/typetalk"
"github.com/markbates/goth/providers/uber"
"github.com/markbates/goth/providers/wepay"
"github.com/markbates/goth/providers/xero"
"github.com/markbates/goth/providers/yahoo"
"github.com/markbates/goth/providers/yammer"
"github.com/markbates/goth/providers/yandex"
"github.com/markbates/goth/providers/zoom"
"golang.org/x/oauth2"
@ -77,11 +106,41 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Provider: azureadv2.New(clientId, clientSecret, redirectUrl, azureadv2.ProviderOptions{Tenant: "common"}),
Session: &azureadv2.Session{},
}
case "Auth0":
idp = GothIdProvider{
Provider: auth0.New(clientId, clientSecret, redirectUrl, "casdoor.auth0.com"),
Session: &auth0.Session{},
}
case "BattleNet":
idp = GothIdProvider{
Provider: battlenet.New(clientId, clientSecret, redirectUrl),
Session: &battlenet.Session{},
}
case "Bitbucket":
idp = GothIdProvider{
Provider: bitbucket.New(clientId, clientSecret, redirectUrl),
Session: &bitbucket.Session{},
}
case "Box":
idp = GothIdProvider{
Provider: box.New(clientId, clientSecret, redirectUrl),
Session: &box.Session{},
}
case "CloudFoundry":
idp = GothIdProvider{
Provider: cloudfoundry.New("", clientId, clientSecret, redirectUrl),
Session: &cloudfoundry.Session{},
}
case "Dailymotion":
idp = GothIdProvider{
Provider: dailymotion.New(clientId, clientSecret, redirectUrl),
Session: &dailymotion.Session{},
}
case "Deezer":
idp = GothIdProvider{
Provider: deezer.New(clientId, clientSecret, redirectUrl),
Session: &deezer.Session{},
}
case "DigitalOcean":
idp = GothIdProvider{
Provider: digitalocean.New(clientId, clientSecret, redirectUrl),
@ -97,6 +156,16 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Provider: dropbox.New(clientId, clientSecret, redirectUrl),
Session: &dropbox.Session{},
}
case "EveOnline":
idp = GothIdProvider{
Provider: eveonline.New(clientId, clientSecret, redirectUrl),
Session: &eveonline.Session{},
}
case "Fitbit":
idp = GothIdProvider{
Provider: fitbit.New(clientId, clientSecret, redirectUrl),
Session: &fitbit.Session{},
}
case "Facebook":
idp = GothIdProvider{
Provider: facebook.New(clientId, clientSecret, redirectUrl),
@ -127,16 +196,31 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Provider: heroku.New(clientId, clientSecret, redirectUrl),
Session: &heroku.Session{},
}
case "InfluxCloud":
idp = GothIdProvider{
Provider: influxcloud.New(clientId, clientSecret, redirectUrl),
Session: &influxcloud.Session{},
}
case "Instagram":
idp = GothIdProvider{
Provider: instagram.New(clientId, clientSecret, redirectUrl),
Session: &instagram.Session{},
}
case "Intercom":
idp = GothIdProvider{
Provider: intercom.New(clientId, clientSecret, redirectUrl),
Session: &intercom.Session{},
}
case "Kakao":
idp = GothIdProvider{
Provider: kakao.New(clientId, clientSecret, redirectUrl),
Session: &kakao.Session{},
}
case "Lastfm":
idp = GothIdProvider{
Provider: lastfm.New(clientId, clientSecret, redirectUrl),
Session: &lastfm.Session{},
}
case "Linkedin":
idp = GothIdProvider{
Provider: linkedin.New(clientId, clientSecret, redirectUrl),
@ -147,11 +231,46 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Provider: line.New(clientId, clientSecret, redirectUrl),
Session: &line.Session{},
}
case "Mailru":
idp = GothIdProvider{
Provider: mailru.New(clientId, clientSecret, redirectUrl),
Session: &mailru.Session{},
}
case "Meetup":
idp = GothIdProvider{
Provider: meetup.New(clientId, clientSecret, redirectUrl),
Session: &meetup.Session{},
}
case "MicrosoftOnline":
idp = GothIdProvider{
Provider: microsoftonline.New(clientId, clientSecret, redirectUrl),
Session: &microsoftonline.Session{},
}
case "Naver":
idp = GothIdProvider{
Provider: naver.New(clientId, clientSecret, redirectUrl),
Session: &naver.Session{},
}
case "Nextcloud":
idp = GothIdProvider{
Provider: nextcloud.New(clientId, clientSecret, redirectUrl),
Session: &nextcloud.Session{},
}
case "OneDrive":
idp = GothIdProvider{
Provider: onedrive.New(clientId, clientSecret, redirectUrl),
Session: &onedrive.Session{},
}
case "Oura":
idp = GothIdProvider{
Provider: oura.New(clientId, clientSecret, redirectUrl),
Session: &oura.Session{},
}
case "Patreon":
idp = GothIdProvider{
Provider: patreon.New(clientId, clientSecret, redirectUrl),
Session: &patreon.Session{},
}
case "Paypal":
idp = GothIdProvider{
Provider: paypal.New(clientId, clientSecret, redirectUrl),
@ -172,26 +291,81 @@ func NewGothIdProvider(providerType string, clientId string, clientSecret string
Provider: slack.New(clientId, clientSecret, redirectUrl),
Session: &slack.Session{},
}
case "Soundcloud":
idp = GothIdProvider{
Provider: soundcloud.New(clientId, clientSecret, redirectUrl),
Session: &soundcloud.Session{},
}
case "Spotify":
idp = GothIdProvider{
Provider: spotify.New(clientId, clientSecret, redirectUrl),
Session: &spotify.Session{},
}
case "Steam":
idp = GothIdProvider{
Provider: steam.New(clientSecret, redirectUrl),
Session: &steam.Session{},
}
case "Strava":
idp = GothIdProvider{
Provider: strava.New(clientId, clientSecret, redirectUrl),
Session: &strava.Session{},
}
case "Stripe":
idp = GothIdProvider{
Provider: stripe.New(clientId, clientSecret, redirectUrl),
Session: &stripe.Session{},
}
case "TikTok":
idp = GothIdProvider{
Provider: tiktok.New(clientId, clientSecret, redirectUrl),
Session: &tiktok.Session{},
}
case "Tumblr":
idp = GothIdProvider{
Provider: tumblr.New(clientId, clientSecret, redirectUrl),
Session: &tumblr.Session{},
}
case "Twitch":
idp = GothIdProvider{
Provider: twitch.New(clientId, clientSecret, redirectUrl),
Session: &twitch.Session{},
}
case "Twitter":
idp = GothIdProvider{
Provider: twitter.New(clientId, clientSecret, redirectUrl),
Session: &twitter.Session{},
Provider: twitterv2.New(clientId, clientSecret, redirectUrl),
Session: &twitterv2.Session{},
}
case "Typetalk":
idp = GothIdProvider{
Provider: typetalk.New(clientId, clientSecret, redirectUrl),
Session: &typetalk.Session{},
}
case "Uber":
idp = GothIdProvider{
Provider: uber.New(clientId, clientSecret, redirectUrl),
Session: &uber.Session{},
}
case "Wepay":
idp = GothIdProvider{
Provider: wepay.New(clientId, clientSecret, redirectUrl),
Session: &wepay.Session{},
}
case "Xero":
idp = GothIdProvider{
Provider: xero.New(clientId, clientSecret, redirectUrl),
Session: &xero.Session{},
}
case "Yahoo":
idp = GothIdProvider{
Provider: yahoo.New(clientId, clientSecret, redirectUrl),
Session: &yahoo.Session{},
}
case "Yammer":
idp = GothIdProvider{
Provider: yammer.New(clientId, clientSecret, redirectUrl),
Session: &yammer.Session{},
}
case "Yandex":
idp = GothIdProvider{
Provider: yandex.New(clientId, clientSecret, redirectUrl),
@ -232,6 +406,9 @@ func (idp *GothIdProvider) GetToken(code string) (*oauth2.Token, error) {
// to call the function to obtain accessToken
value = url.Values{}
value.Add("code", code)
if idp.Provider.Name() == "twitterv2" || idp.Provider.Name() == "fitbit" {
value.Add("oauth_verifier", "casdoor-verifier")
}
}
accessToken, err := idp.Session.Authorize(idp.Provider, value)
if err != nil {

View File

@ -98,7 +98,61 @@ func GetIdProvider(typ string, subType string, clientId string, clientSecret str
return nil
}
var gothList = []string{"Apple", "AzureAD", "Slack", "Steam", "Line"}
var gothList = []string{
"Apple",
"AzureAD",
"Slack",
"Steam",
"Line",
"Amazon",
"Auth0",
"BattleNet",
"Bitbucket",
"Box",
"CloudFoundry",
"Dailymotion",
"Deezer",
"DigitalOcean",
"Discord",
"Dropbox",
"EveOnline",
"Fitbit",
"Gitea",
"Heroku",
"InfluxCloud",
"Instagram",
"Intercom",
"Kakao",
"Lastfm",
"Mailru",
"Meetup",
"MicrosoftOnline",
"Naver",
"Nextcloud",
"OneDrive",
"Oura",
"Patreon",
"Paypal",
"SalesForce",
"Shopify",
"Soundcloud",
"Spotify",
"Strava",
"Stripe",
"TikTok",
"Tumblr",
"Twitch",
"Twitter",
"Typetalk",
"Uber",
"VK",
"Wepay",
"Xero",
"Yahoo",
"Yammer",
"Yandex",
"Zoom",
}
func isGothSupport(provider string) bool {
for _, value := range gothList {

View File

@ -28,7 +28,6 @@ import (
_ "modernc.org/sqlite" // db = sqlite
"xorm.io/core"
"xorm.io/xorm"
"xorm.io/xorm/migrate"
)
var adapter *Adapter
@ -42,7 +41,7 @@ func InitConfig() {
beego.BConfig.WebConfig.Session.SessionOn = true
InitAdapter(true)
initMigrations()
MigrateDatabase()
}
func InitAdapter(createDatabase bool) {
@ -252,22 +251,3 @@ func GetSession(owner string, offset, limit int, field, value, sortField, sortOr
}
return session
}
func initMigrations() {
migrations := []*migrate.Migration{
{
ID: "20221015CasbinRule--fill ptype field with p",
Migrate: func(tx *xorm.Engine) error {
_, err := tx.Cols("ptype").Update(&xormadapter.CasbinRule{
Ptype: "p",
})
return err
},
Rollback: func(tx *xorm.Engine) error {
return tx.DropTables(&xormadapter.CasbinRule{})
},
},
}
m := migrate.New(adapter.Engine, migrate.DefaultOptions, migrations)
m.Migrate()
}

View File

@ -25,8 +25,6 @@ import (
)
func InitDb() {
MigratePermissionRule()
existed := initBuiltInOrganization()
if !existed {
initBuiltInModel()
@ -36,6 +34,8 @@ func InitDb() {
initBuiltInApplication()
initBuiltInCert()
initBuiltInLdap()
} else {
MigrateDatabase()
}
initWebAuthn()

85
object/migrate.go Normal file
View File

@ -0,0 +1,85 @@
// Copyright 2023 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.package object
package object
import (
"strings"
xormadapter "github.com/casbin/xorm-adapter/v3"
"xorm.io/xorm"
"xorm.io/xorm/migrate"
)
func MigrateDatabase() {
migrations := []*migrate.Migration{
MigrateCasbinRule(),
MigratePermissionRule(),
}
m := migrate.New(adapter.Engine, migrate.DefaultOptions, migrations)
m.Migrate()
}
func MigrateCasbinRule() *migrate.Migration {
migration := migrate.Migration{
ID: "20221015CasbinRule--fill ptype field with p",
Migrate: func(engine *xorm.Engine) error {
_, err := engine.Cols("ptype").Update(&xormadapter.CasbinRule{
Ptype: "p",
})
return err
},
Rollback: func(engine *xorm.Engine) error {
return engine.DropTables(&xormadapter.CasbinRule{})
},
}
return &migration
}
func MigratePermissionRule() *migrate.Migration {
migration := migrate.Migration{
ID: "20230209MigratePermissionRule--Use V5 instead of V1 to store permissionID",
Migrate: func(engine *xorm.Engine) error {
models := []*Model{}
err := engine.Find(&models, &Model{})
if err != nil {
panic(err)
}
isHit := false
for _, model := range models {
if strings.Contains(model.ModelText, "permission") {
// update model table
model.ModelText = strings.Replace(model.ModelText, "permission,", "", -1)
UpdateModel(model.GetId(), model)
isHit = true
}
}
if isHit {
// update permission_rule table
sql := "UPDATE `permission_rule`SET V0 = V1, V1 = V2, V2 = V3, V3 = V4, V4 = V5 WHERE V0 IN (SELECT CONCAT(owner, '/', name) AS permission_id FROM `permission`)"
_, err = engine.Exec(sql)
if err != nil {
return err
}
}
return err
},
}
return &migration
}

View File

@ -16,7 +16,6 @@ package object
import (
"fmt"
"strings"
"github.com/casdoor/casdoor/util"
"xorm.io/core"
@ -269,33 +268,6 @@ func GetPermissionsBySubmitter(owner string, submitter string) []*Permission {
return permissions
}
func MigratePermissionRule() {
models := []*Model{}
err := adapter.Engine.Find(&models, &Model{})
if err != nil {
panic(err)
}
isHit := false
for _, model := range models {
if strings.Contains(model.ModelText, "permission") {
// update model table
model.ModelText = strings.Replace(model.ModelText, "permission,", "", -1)
UpdateModel(model.GetId(), model)
isHit = true
}
}
if isHit {
// update permission_rule table
sql := "UPDATE `permission_rule`SET V0 = V1, V1 = V2, V2 = V3, V3 = V4, V4 = V5 WHERE V0 IN (SELECT CONCAT(owner, '/', name) AS permission_id FROM `permission`)"
_, err = adapter.Engine.Exec(sql)
if err != nil {
return
}
}
}
func ContainsAsterisk(userId string, users []string) bool {
containsAsterisk := false
group, _ := util.GetOwnerAndNameFromId(userId)

View File

@ -23,7 +23,7 @@ import (
type Resource struct {
Owner string `xorm:"varchar(100) notnull pk" json:"owner"`
Name string `xorm:"varchar(100) notnull pk" json:"name"`
Name string `xorm:"varchar(180) notnull pk" json:"name"`
CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
User string `xorm:"varchar(100)" json:"user"`

View File

@ -74,10 +74,15 @@ func GetUploadFileUrl(provider *Provider, fullFilePath string, hasTimestamp bool
}
fileUrl := util.UrlJoin(host, escapePath(objectKey))
if hasTimestamp {
fileUrl = fmt.Sprintf("%s?t=%s", fileUrl, util.GetCurrentUnixTime())
}
if provider.Type == "Tencent Cloud COS" {
objectKey = escapePath(objectKey)
}
return fileUrl, objectKey
}

View File

@ -78,32 +78,80 @@ type User struct {
LastSigninTime string `xorm:"varchar(100)" json:"lastSigninTime"`
LastSigninIp string `xorm:"varchar(100)" json:"lastSigninIp"`
GitHub string `xorm:"github varchar(100)" json:"github"`
Google string `xorm:"varchar(100)" json:"google"`
QQ string `xorm:"qq varchar(100)" json:"qq"`
WeChat string `xorm:"wechat varchar(100)" json:"wechat"`
Facebook string `xorm:"facebook varchar(100)" json:"facebook"`
DingTalk string `xorm:"dingtalk varchar(100)" json:"dingtalk"`
Weibo string `xorm:"weibo varchar(100)" json:"weibo"`
Gitee string `xorm:"gitee varchar(100)" json:"gitee"`
LinkedIn string `xorm:"linkedin varchar(100)" json:"linkedin"`
Wecom string `xorm:"wecom varchar(100)" json:"wecom"`
Lark string `xorm:"lark varchar(100)" json:"lark"`
Gitlab string `xorm:"gitlab varchar(100)" json:"gitlab"`
Adfs string `xorm:"adfs varchar(100)" json:"adfs"`
Baidu string `xorm:"baidu varchar(100)" json:"baidu"`
Alipay string `xorm:"alipay varchar(100)" json:"alipay"`
Casdoor string `xorm:"casdoor varchar(100)" json:"casdoor"`
Infoflow string `xorm:"infoflow varchar(100)" json:"infoflow"`
Apple string `xorm:"apple varchar(100)" json:"apple"`
AzureAD string `xorm:"azuread varchar(100)" json:"azuread"`
Slack string `xorm:"slack varchar(100)" json:"slack"`
Steam string `xorm:"steam varchar(100)" json:"steam"`
Bilibili string `xorm:"bilibili varchar(100)" json:"bilibili"`
Okta string `xorm:"okta varchar(100)" json:"okta"`
Douyin string `xorm:"douyin varchar(100)" json:"douyin"`
Line string `xorm:"line varchar(100)" json:"line"`
Custom string `xorm:"custom varchar(100)" json:"custom"`
GitHub string `xorm:"github varchar(100)" json:"github"`
Google string `xorm:"varchar(100)" json:"google"`
QQ string `xorm:"qq varchar(100)" json:"qq"`
WeChat string `xorm:"wechat varchar(100)" json:"wechat"`
Facebook string `xorm:"facebook varchar(100)" json:"facebook"`
DingTalk string `xorm:"dingtalk varchar(100)" json:"dingtalk"`
Weibo string `xorm:"weibo varchar(100)" json:"weibo"`
Gitee string `xorm:"gitee varchar(100)" json:"gitee"`
LinkedIn string `xorm:"linkedin varchar(100)" json:"linkedin"`
Wecom string `xorm:"wecom varchar(100)" json:"wecom"`
Lark string `xorm:"lark varchar(100)" json:"lark"`
Gitlab string `xorm:"gitlab varchar(100)" json:"gitlab"`
Adfs string `xorm:"adfs varchar(100)" json:"adfs"`
Baidu string `xorm:"baidu varchar(100)" json:"baidu"`
Alipay string `xorm:"alipay varchar(100)" json:"alipay"`
Casdoor string `xorm:"casdoor varchar(100)" json:"casdoor"`
Infoflow string `xorm:"infoflow varchar(100)" json:"infoflow"`
Apple string `xorm:"apple varchar(100)" json:"apple"`
AzureAD string `xorm:"azuread varchar(100)" json:"azuread"`
Slack string `xorm:"slack varchar(100)" json:"slack"`
Steam string `xorm:"steam varchar(100)" json:"steam"`
Bilibili string `xorm:"bilibili varchar(100)" json:"bilibili"`
Okta string `xorm:"okta varchar(100)" json:"okta"`
Douyin string `xorm:"douyin varchar(100)" json:"douyin"`
Line string `xorm:"line varchar(100)" json:"line"`
Amazon string `xorm:"amazon varchar(100)" json:"amazon"`
Auth0 string `xorm:"auth0 varchar(100)" json:"auth0"`
BattleNet string `xorm:"battlenet varchar(100)" json:"battlenet"`
Bitbucket string `xorm:"bitbucket varchar(100)" json:"bitbucket"`
Box string `xorm:"box varchar(100)" json:"box"`
CloudFoundry string `xorm:"cloudfoundry varchar(100)" json:"cloudfoundry"`
Dailymotion string `xorm:"dailymotion varchar(100)" json:"dailymotion"`
Deezer string `xorm:"deezer varchar(100)" json:"deezer"`
DigitalOcean string `xorm:"digitalocean varchar(100)" json:"digitalocean"`
Discord string `xorm:"discord varchar(100)" json:"discord"`
Dropbox string `xorm:"dropbox varchar(100)" json:"dropbox"`
EveOnline string `xorm:"eveonline varchar(100)" json:"eveonline"`
Fitbit string `xorm:"fitbit varchar(100)" json:"fitbit"`
Gitea string `xorm:"gitea varchar(100)" json:"gitea"`
Heroku string `xorm:"heroku varchar(100)" json:"heroku"`
InfluxCloud string `xorm:"influxcloud varchar(100)" json:"influxcloud"`
Instagram string `xorm:"instagram varchar(100)" json:"instagram"`
Intercom string `xorm:"intercom varchar(100)" json:"intercom"`
Kakao string `xorm:"kakao varchar(100)" json:"kakao"`
Lastfm string `xorm:"lastfm varchar(100)" json:"lastfm"`
Mailru string `xorm:"mailru varchar(100)" json:"mailru"`
Meetup string `xorm:"meetup varchar(100)" json:"meetup"`
MicrosoftOnline string `xorm:"microsoftonline varchar(100)" json:"microsoftonline"`
Naver string `xorm:"naver varchar(100)" json:"naver"`
Nextcloud string `xorm:"nextcloud varchar(100)" json:"nextcloud"`
OneDrive string `xorm:"onedrive varchar(100)" json:"onedrive"`
Oura string `xorm:"oura varchar(100)" json:"oura"`
Patreon string `xorm:"patreon varchar(100)" json:"patreon"`
Paypal string `xorm:"paypal varchar(100)" json:"paypal"`
SalesForce string `xorm:"salesforce varchar(100)" json:"salesforce"`
Shopify string `xorm:"shopify varchar(100)" json:"shopify"`
Soundcloud string `xorm:"soundcloud varchar(100)" json:"soundcloud"`
Spotify string `xorm:"spotify varchar(100)" json:"spotify"`
Strava string `xorm:"strava varchar(100)" json:"strava"`
Stripe string `xorm:"stripe varchar(100)" json:"stripe"`
TikTok string `xorm:"tiktok varchar(100)" json:"tiktok"`
Tumblr string `xorm:"tumblr varchar(100)" json:"tumblr"`
Twitch string `xorm:"twitch varchar(100)" json:"twitch"`
Twitter string `xorm:"twitter varchar(100)" json:"twitter"`
Typetalk string `xorm:"typetalk varchar(100)" json:"typetalk"`
Uber string `xorm:"uber varchar(100)" json:"uber"`
VK string `xorm:"vk varchar(100)" json:"vk"`
Wepay string `xorm:"wepay varchar(100)" json:"wepay"`
Xero string `xorm:"xero varchar(100)" json:"xero"`
Yahoo string `xorm:"yahoo varchar(100)" json:"yahoo"`
Yammer string `xorm:"yammer varchar(100)" json:"yammer"`
Yandex string `xorm:"yandex varchar(100)" json:"yandex"`
Zoom string `xorm:"zoom varchar(100)" json:"zoom"`
Custom string `xorm:"custom varchar(100)" json:"custom"`
WebauthnCredentials []webauthn.Credential `xorm:"webauthnCredentials blob" json:"webauthnCredentials"`

View File

@ -578,7 +578,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the product",
"description": "The id ( owner/name ) of the product",
"required": true,
"type": "string"
},
@ -894,8 +894,8 @@
"parameters": [
{
"in": "query",
"name": "ID",
"description": "The ID(owner/name) of user.",
"name": "id",
"description": "The id ( owner/name )(owner/name) of user.",
"required": true,
"type": "string"
}
@ -1107,7 +1107,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the application.",
"description": "The id ( owner/name ) of the application.",
"required": true,
"type": "string"
}
@ -1162,7 +1162,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the cert",
"description": "The id ( owner/name ) of the cert",
"required": true,
"type": "string"
}
@ -1340,7 +1340,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the model",
"description": "The id ( owner/name ) of the model",
"required": true,
"type": "string"
}
@ -1479,7 +1479,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the payment",
"description": "The id ( owner/name ) of the payment",
"required": true,
"type": "string"
}
@ -1534,7 +1534,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the permission",
"description": "The id ( owner/name ) of the permission",
"required": true,
"type": "string"
}
@ -1589,7 +1589,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the role",
"description": "The id ( owner/name ) of the role",
"required": true,
"type": "string"
}
@ -1638,7 +1638,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the product",
"description": "The id ( owner/name ) of the product",
"required": true,
"type": "string"
}
@ -1693,7 +1693,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the provider",
"description": "The id ( owner/name ) of the provider",
"required": true,
"type": "string"
}
@ -1840,7 +1840,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the role",
"description": "The id ( owner/name ) of the role",
"required": true,
"type": "string"
}
@ -1966,7 +1966,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the syncer",
"description": "The id ( owner/name ) of the syncer",
"required": true,
"type": "string"
}
@ -2021,7 +2021,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the user",
"description": "The id ( owner/name ) of the user",
"required": true,
"type": "string"
}
@ -2047,7 +2047,7 @@
{
"in": "query",
"name": "id",
"description": "The id of token",
"description": "The id ( owner/name ) of token",
"required": true,
"type": "string"
}
@ -2116,7 +2116,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the user",
"description": "The id ( owner/name ) of the user",
"required": true,
"type": "string"
},
@ -2160,7 +2160,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the user",
"description": "The id ( owner/name ) of the user",
"required": true,
"type": "string"
}
@ -2286,7 +2286,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the webhook",
"description": "The id ( owner/name ) of the webhook",
"required": true,
"type": "string"
}
@ -2341,7 +2341,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the payment",
"description": "The id ( owner/name ) of the payment",
"required": true,
"type": "string"
}
@ -2504,8 +2504,8 @@
"parameters": [
{
"in": "query",
"name": "user_id",
"description": "The id of user",
"name": "id",
"description": "The id ( owner/name ) of user",
"required": true,
"type": "string"
},
@ -2904,7 +2904,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the application",
"description": "The id ( owner/name ) of the application",
"required": true,
"type": "string"
},
@ -2939,7 +2939,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the cert",
"description": "The id ( owner/name ) of the cert",
"required": true,
"type": "string"
},
@ -2982,7 +2982,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the model",
"description": "The id ( owner/name ) of the model",
"required": true,
"type": "string"
},
@ -3017,7 +3017,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the organization",
"description": "The id ( owner/name ) of the organization",
"required": true,
"type": "string"
},
@ -3052,7 +3052,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the payment",
"description": "The id ( owner/name ) of the payment",
"required": true,
"type": "string"
},
@ -3087,7 +3087,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the permission",
"description": "The id ( owner/name ) of the permission",
"required": true,
"type": "string"
},
@ -3122,7 +3122,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the product",
"description": "The id ( owner/name ) of the product",
"required": true,
"type": "string"
},
@ -3157,7 +3157,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the provider",
"description": "The id ( owner/name ) of the provider",
"required": true,
"type": "string"
},
@ -3200,7 +3200,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the role",
"description": "The id ( owner/name ) of the role",
"required": true,
"type": "string"
},
@ -3235,7 +3235,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the syncer",
"description": "The id ( owner/name ) of the syncer",
"required": true,
"type": "string"
},
@ -3270,7 +3270,7 @@
{
"in": "query",
"name": "id",
"description": "The id of token",
"description": "The id ( owner/name ) of token",
"required": true,
"type": "string"
},
@ -3305,7 +3305,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the user",
"description": "The id ( owner/name ) of the user",
"required": true,
"type": "string"
},
@ -3340,7 +3340,7 @@
{
"in": "query",
"name": "id",
"description": "The id of the webhook",
"description": "The id ( owner/name ) of the webhook",
"required": true,
"type": "string"
},
@ -3505,11 +3505,11 @@
}
},
"definitions": {
"2268.0xc0000f9650.false": {
"2346.0xc0001ce990.false": {
"title": "false",
"type": "object"
},
"2302.0xc0000f9680.false": {
"2381.0xc0001ce9c0.false": {
"title": "false",
"type": "object"
},
@ -3636,10 +3636,10 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/2268.0xc0000f9650.false"
"$ref": "#/definitions/2346.0xc0001ce990.false"
},
"data2": {
"$ref": "#/definitions/2302.0xc0000f9680.false"
"$ref": "#/definitions/2381.0xc0001ce9c0.false"
},
"msg": {
"type": "string"
@ -3846,6 +3846,9 @@
"termsOfUse": {
"type": "string"
},
"themeData": {
"$ref": "#/definitions/object.ThemeData"
},
"tokenFormat": {
"type": "string"
}
@ -4143,6 +4146,9 @@
"type": "string"
}
},
"themeData": {
"$ref": "#/definitions/object.ThemeData"
},
"websiteUrl": {
"type": "string"
}
@ -4727,6 +4733,28 @@
}
}
},
"object.ThemeData": {
"title": "ThemeData",
"type": "object",
"properties": {
"borderRadius": {
"type": "integer",
"format": "int64"
},
"colorPrimary": {
"type": "string"
},
"isCompact": {
"type": "boolean"
},
"isEnabled": {
"type": "boolean"
},
"themeType": {
"type": "string"
}
}
},
"object.Token": {
"title": "Token",
"type": "object",
@ -4836,9 +4864,15 @@
"alipay": {
"type": "string"
},
"amazon": {
"type": "string"
},
"apple": {
"type": "string"
},
"auth0": {
"type": "string"
},
"avatar": {
"type": "string"
},
@ -4848,6 +4882,9 @@
"baidu": {
"type": "string"
},
"battlenet": {
"type": "string"
},
"bilibili": {
"type": "string"
},
@ -4857,9 +4894,18 @@
"birthday": {
"type": "string"
},
"bitbucket": {
"type": "string"
},
"box": {
"type": "string"
},
"casdoor": {
"type": "string"
},
"cloudfoundry": {
"type": "string"
},
"createdIp": {
"type": "string"
},
@ -4869,15 +4915,30 @@
"custom": {
"type": "string"
},
"dailymotion": {
"type": "string"
},
"deezer": {
"type": "string"
},
"digitalocean": {
"type": "string"
},
"dingtalk": {
"type": "string"
},
"discord": {
"type": "string"
},
"displayName": {
"type": "string"
},
"douyin": {
"type": "string"
},
"dropbox": {
"type": "string"
},
"education": {
"type": "string"
},
@ -4887,15 +4948,24 @@
"emailVerified": {
"type": "boolean"
},
"eveonline": {
"type": "string"
},
"facebook": {
"type": "string"
},
"firstName": {
"type": "string"
},
"fitbit": {
"type": "string"
},
"gender": {
"type": "string"
},
"gitea": {
"type": "string"
},
"gitee": {
"type": "string"
},
@ -4911,6 +4981,9 @@
"hash": {
"type": "string"
},
"heroku": {
"type": "string"
},
"homepage": {
"type": "string"
},
@ -4923,9 +4996,18 @@
"idCardType": {
"type": "string"
},
"influxcloud": {
"type": "string"
},
"infoflow": {
"type": "string"
},
"instagram": {
"type": "string"
},
"intercom": {
"type": "string"
},
"isAdmin": {
"type": "boolean"
},
@ -4944,6 +5026,9 @@
"isOnline": {
"type": "boolean"
},
"kakao": {
"type": "string"
},
"karma": {
"type": "integer",
"format": "int64"
@ -4966,6 +5051,9 @@
"lastSigninWrongTime": {
"type": "string"
},
"lastfm": {
"type": "string"
},
"ldap": {
"type": "string"
},
@ -4978,18 +5066,39 @@
"location": {
"type": "string"
},
"mailru": {
"type": "string"
},
"managedAccounts": {
"type": "array",
"items": {
"$ref": "#/definitions/object.ManagedAccount"
}
},
"meetup": {
"type": "string"
},
"microsoftonline": {
"type": "string"
},
"name": {
"type": "string"
},
"naver": {
"type": "string"
},
"nextcloud": {
"type": "string"
},
"okta": {
"type": "string"
},
"onedrive": {
"type": "string"
},
"oura": {
"type": "string"
},
"owner": {
"type": "string"
},
@ -4999,6 +5108,12 @@
"passwordSalt": {
"type": "string"
},
"patreon": {
"type": "string"
},
"paypal": {
"type": "string"
},
"permanentAvatar": {
"type": "string"
},
@ -5035,10 +5150,16 @@
"$ref": "#/definitions/object.Role"
}
},
"salesforce": {
"type": "string"
},
"score": {
"type": "integer",
"format": "int64"
},
"shopify": {
"type": "string"
},
"signinWrongTimes": {
"type": "integer",
"format": "int64"
@ -5049,21 +5170,54 @@
"slack": {
"type": "string"
},
"soundcloud": {
"type": "string"
},
"spotify": {
"type": "string"
},
"steam": {
"type": "string"
},
"strava": {
"type": "string"
},
"stripe": {
"type": "string"
},
"tag": {
"type": "string"
},
"tiktok": {
"type": "string"
},
"title": {
"type": "string"
},
"tumblr": {
"type": "string"
},
"twitch": {
"type": "string"
},
"twitter": {
"type": "string"
},
"type": {
"type": "string"
},
"typetalk": {
"type": "string"
},
"uber": {
"type": "string"
},
"updatedTime": {
"type": "string"
},
"vk": {
"type": "string"
},
"webauthnCredentials": {
"type": "array",
"items": {
@ -5078,6 +5232,24 @@
},
"weibo": {
"type": "string"
},
"wepay": {
"type": "string"
},
"xero": {
"type": "string"
},
"yahoo": {
"type": "string"
},
"yammer": {
"type": "string"
},
"yandex": {
"type": "string"
},
"zoom": {
"type": "string"
}
}
},

View File

@ -375,7 +375,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the product
description: The id ( owner/name ) of the product
required: true
type: string
- in: query
@ -578,8 +578,8 @@ paths:
operationId: ApiController.DeleteSession
parameters:
- in: query
name: ID
description: The ID(owner/name) of user.
name: id
description: The id ( owner/name )(owner/name) of user.
required: true
type: string
responses:
@ -718,7 +718,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the application.
description: The id ( owner/name ) of the application.
required: true
type: string
responses:
@ -754,7 +754,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the cert
description: The id ( owner/name ) of the cert
required: true
type: string
responses:
@ -870,7 +870,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the model
description: The id ( owner/name ) of the model
required: true
type: string
responses:
@ -961,7 +961,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the payment
description: The id ( owner/name ) of the payment
required: true
type: string
responses:
@ -997,7 +997,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the permission
description: The id ( owner/name ) of the permission
required: true
type: string
responses:
@ -1033,7 +1033,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the role
description: The id ( owner/name ) of the role
required: true
type: string
responses:
@ -1065,7 +1065,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the product
description: The id ( owner/name ) of the product
required: true
type: string
responses:
@ -1101,7 +1101,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the provider
description: The id ( owner/name ) of the provider
required: true
type: string
responses:
@ -1197,7 +1197,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the role
description: The id ( owner/name ) of the role
required: true
type: string
responses:
@ -1280,7 +1280,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the syncer
description: The id ( owner/name ) of the syncer
required: true
type: string
responses:
@ -1316,7 +1316,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the user
description: The id ( owner/name ) of the user
required: true
type: string
responses:
@ -1333,7 +1333,7 @@ paths:
parameters:
- in: query
name: id
description: The id of token
description: The id ( owner/name ) of token
required: true
type: string
responses:
@ -1379,7 +1379,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the user
description: The id ( owner/name ) of the user
required: true
type: string
- in: query
@ -1408,7 +1408,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the user
description: The id ( owner/name ) of the user
required: true
type: string
responses:
@ -1491,7 +1491,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the webhook
description: The id ( owner/name ) of the webhook
required: true
type: string
responses:
@ -1527,7 +1527,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the payment
description: The id ( owner/name ) of the payment
required: true
type: string
responses:
@ -1636,8 +1636,8 @@ paths:
operationId: ApiController.GetOAuthCode
parameters:
- in: query
name: user_id
description: The id of user
name: id
description: The id ( owner/name ) of user
required: true
type: string
- in: query
@ -1902,7 +1902,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the application
description: The id ( owner/name ) of the application
required: true
type: string
- in: body
@ -1925,7 +1925,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the cert
description: The id ( owner/name ) of the cert
required: true
type: string
- in: body
@ -1953,7 +1953,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the model
description: The id ( owner/name ) of the model
required: true
type: string
- in: body
@ -1976,7 +1976,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the organization
description: The id ( owner/name ) of the organization
required: true
type: string
- in: body
@ -1999,7 +1999,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the payment
description: The id ( owner/name ) of the payment
required: true
type: string
- in: body
@ -2022,7 +2022,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the permission
description: The id ( owner/name ) of the permission
required: true
type: string
- in: body
@ -2045,7 +2045,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the product
description: The id ( owner/name ) of the product
required: true
type: string
- in: body
@ -2068,7 +2068,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the provider
description: The id ( owner/name ) of the provider
required: true
type: string
- in: body
@ -2096,7 +2096,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the role
description: The id ( owner/name ) of the role
required: true
type: string
- in: body
@ -2119,7 +2119,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the syncer
description: The id ( owner/name ) of the syncer
required: true
type: string
- in: body
@ -2142,7 +2142,7 @@ paths:
parameters:
- in: query
name: id
description: The id of token
description: The id ( owner/name ) of token
required: true
type: string
- in: body
@ -2165,7 +2165,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the user
description: The id ( owner/name ) of the user
required: true
type: string
- in: body
@ -2188,7 +2188,7 @@ paths:
parameters:
- in: query
name: id
description: The id of the webhook
description: The id ( owner/name ) of the webhook
required: true
type: string
- in: body
@ -2293,10 +2293,10 @@ paths:
schema:
$ref: '#/definitions/Response'
definitions:
2268.0xc0000f9650.false:
2346.0xc0001ce990.false:
title: "false"
type: object
2302.0xc0000f9680.false:
2381.0xc0001ce9c0.false:
title: "false"
type: object
Response:
@ -2383,9 +2383,9 @@ definitions:
type: object
properties:
data:
$ref: '#/definitions/2268.0xc0000f9650.false'
$ref: '#/definitions/2346.0xc0001ce990.false'
data2:
$ref: '#/definitions/2302.0xc0000f9680.false'
$ref: '#/definitions/2381.0xc0001ce9c0.false'
msg:
type: string
name:
@ -2524,6 +2524,8 @@ definitions:
type: string
termsOfUse:
type: string
themeData:
$ref: '#/definitions/object.ThemeData'
tokenFormat:
type: string
object.Cert:
@ -2724,6 +2726,8 @@ definitions:
type: array
items:
type: string
themeData:
$ref: '#/definitions/object.ThemeData'
websiteUrl:
type: string
object.Payment:
@ -3115,6 +3119,21 @@ definitions:
type: array
items:
type: string
object.ThemeData:
title: ThemeData
type: object
properties:
borderRadius:
type: integer
format: int64
colorPrimary:
type: string
isCompact:
type: boolean
isEnabled:
type: boolean
themeType:
type: string
object.Token:
title: Token
type: object
@ -3190,46 +3209,74 @@ definitions:
type: string
alipay:
type: string
amazon:
type: string
apple:
type: string
auth0:
type: string
avatar:
type: string
azuread:
type: string
baidu:
type: string
battlenet:
type: string
bilibili:
type: string
bio:
type: string
birthday:
type: string
bitbucket:
type: string
box:
type: string
casdoor:
type: string
cloudfoundry:
type: string
createdIp:
type: string
createdTime:
type: string
custom:
type: string
dailymotion:
type: string
deezer:
type: string
digitalocean:
type: string
dingtalk:
type: string
discord:
type: string
displayName:
type: string
douyin:
type: string
dropbox:
type: string
education:
type: string
email:
type: string
emailVerified:
type: boolean
eveonline:
type: string
facebook:
type: string
firstName:
type: string
fitbit:
type: string
gender:
type: string
gitea:
type: string
gitee:
type: string
github:
@ -3240,6 +3287,8 @@ definitions:
type: string
hash:
type: string
heroku:
type: string
homepage:
type: string
id:
@ -3248,8 +3297,14 @@ definitions:
type: string
idCardType:
type: string
influxcloud:
type: string
infoflow:
type: string
instagram:
type: string
intercom:
type: string
isAdmin:
type: boolean
isDefaultAvatar:
@ -3262,6 +3317,8 @@ definitions:
type: boolean
isOnline:
type: boolean
kakao:
type: string
karma:
type: integer
format: int64
@ -3277,6 +3334,8 @@ definitions:
type: string
lastSigninWrongTime:
type: string
lastfm:
type: string
ldap:
type: string
line:
@ -3285,20 +3344,38 @@ definitions:
type: string
location:
type: string
mailru:
type: string
managedAccounts:
type: array
items:
$ref: '#/definitions/object.ManagedAccount'
meetup:
type: string
microsoftonline:
type: string
name:
type: string
naver:
type: string
nextcloud:
type: string
okta:
type: string
onedrive:
type: string
oura:
type: string
owner:
type: string
password:
type: string
passwordSalt:
type: string
patreon:
type: string
paypal:
type: string
permanentAvatar:
type: string
permissions:
@ -3323,9 +3400,13 @@ definitions:
type: array
items:
$ref: '#/definitions/object.Role'
salesforce:
type: string
score:
type: integer
format: int64
shopify:
type: string
signinWrongTimes:
type: integer
format: int64
@ -3333,16 +3414,38 @@ definitions:
type: string
slack:
type: string
soundcloud:
type: string
spotify:
type: string
steam:
type: string
strava:
type: string
stripe:
type: string
tag:
type: string
tiktok:
type: string
title:
type: string
tumblr:
type: string
twitch:
type: string
twitter:
type: string
type:
type: string
typetalk:
type: string
uber:
type: string
updatedTime:
type: string
vk:
type: string
webauthnCredentials:
type: array
items:
@ -3353,6 +3456,18 @@ definitions:
type: string
weibo:
type: string
wepay:
type: string
xero:
type: string
yahoo:
type: string
yammer:
type: string
yandex:
type: string
zoom:
type: string
object.Userinfo:
title: Userinfo
type: object

View File

@ -141,6 +141,8 @@ class ProviderListPage extends BaseListPage {
{text: "SMS", value: "SMS"},
{text: "Storage", value: "Storage"},
{text: "SAML", value: "SAML"},
{text: "Captcha", value: "Captcha"},
{text: "Payment", value: "Payment"},
],
width: "110px",
sorter: true,
@ -159,6 +161,7 @@ class ProviderListPage extends BaseListPage {
{text: "Storage", value: "Storage", children: Setting.getProviderTypeOptions("Storage").map((o) => {return {text: o.id, value: o.name};})},
{text: "SAML", value: "SAML", children: Setting.getProviderTypeOptions("SAML").map((o) => {return {text: o.id, value: o.name};})},
{text: "Captcha", value: "Captcha", children: Setting.getProviderTypeOptions("Captcha").map((o) => {return {text: o.id, value: o.name};})},
{text: "Payment", value: "Payment", children: Setting.getProviderTypeOptions("Payment").map((o) => {return {text: o.id, value: o.name};})},
],
sorter: true,
render: (text, record, index) => {

View File

@ -114,7 +114,11 @@ export const OtherProviderInfo = {
},
Email: {
"Default": {
logo: `${StaticBaseUrl}/img/social_default.png`,
logo: `${StaticBaseUrl}/img/email_default.png`,
url: "",
},
"SUBMAIL": {
logo: `${StaticBaseUrl}/img/social_submail.png`,
url: "",
},
},
@ -174,7 +178,7 @@ export const OtherProviderInfo = {
},
Captcha: {
"Default": {
logo: `${StaticBaseUrl}/img/social_default.png`,
logo: `${StaticBaseUrl}/img/captcha_default.png`,
url: "https://pkg.go.dev/github.com/dchest/captcha",
},
"reCAPTCHA": {
@ -779,6 +783,54 @@ export function getProviderTypeOptions(category) {
{id: "Okta", name: "Okta"},
{id: "Douyin", name: "Douyin"},
{id: "Line", name: "Line"},
{id: "Amazon", name: "Amazon"},
{id: "Auth0", name: "Auth0"},
{id: "BattleNet", name: "Battle.net"},
{id: "Bitbucket", name: "Bitbucket"},
{id: "Box", name: "Box"},
{id: "CloudFoundry", name: "Cloud Foundry"},
{id: "Dailymotion", name: "Dailymotion"},
{id: "Deezer", name: "Deezer"},
{id: "DigitalOcean", name: "DigitalOcean"},
{id: "Discord", name: "Discord"},
{id: "Dropbox", name: "Dropbox"},
{id: "EveOnline", name: "Eve Online"},
{id: "Fitbit", name: "Fitbit"},
{id: "Gitea", name: "Gitea"},
{id: "Heroku", name: "Heroku"},
{id: "InfluxCloud", name: "InfluxCloud"},
{id: "Instagram", name: "Instagram"},
{id: "Intercom", name: "Intercom"},
{id: "Kakao", name: "Kakao"},
{id: "Lastfm", name: "Lastfm"},
{id: "Mailru", name: "Mailru"},
{id: "Meetup", name: "Meetup"},
{id: "MicrosoftOnline", name: "MicrosoftOnline"},
{id: "Naver", name: "Naver"},
{id: "Nextcloud", name: "Nextcloud"},
{id: "OneDrive", name: "OneDrive"},
{id: "Oura", name: "Oura"},
{id: "Patreon", name: "Patreon"},
{id: "Paypal", name: "Paypal"},
{id: "SalesForce", name: "SalesForce"},
{id: "Shopify", name: "Shopify"},
{id: "Soundcloud", name: "Soundcloud"},
{id: "Spotify", name: "Spotify"},
{id: "Strava", name: "Strava"},
{id: "Stripe", name: "Stripe"},
{id: "TikTok", name: "TikTok"},
{id: "Tumblr", name: "Tumblr"},
{id: "Twitch", name: "Twitch"},
{id: "Twitter", name: "Twitter"},
{id: "Typetalk", name: "Typetalk"},
{id: "Uber", name: "Uber"},
{id: "VK", name: "VK"},
{id: "Wepay", name: "Wepay"},
{id: "Xero", name: "Xero"},
{id: "Yahoo", name: "Yahoo"},
{id: "Yammer", name: "Yammer"},
{id: "Yandex", name: "Yandex"},
{id: "Zoom", name: "Zoom"},
{id: "Custom", name: "Custom"},
]
);

View File

@ -1,32 +0,0 @@
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import {createButton} from "react-social-login-buttons";
import {StaticBaseUrl} from "../Setting";
function Icon({width = 24, height = 24, color}) {
return <img src={`${StaticBaseUrl}/buttons/line.svg`} alt="Sign in with Line" style={{width: 24, height: 24}} />;
}
const config = {
text: "Sign in with Line",
icon: Icon,
iconFormat: name => `fa fa-${name}`,
style: {background: "#ffffff", color: "#000000"},
activeStyle: {background: "#ededee"},
};
const LineLoginButton = createButton(config);
export default LineLoginButton;

View File

@ -0,0 +1,34 @@
// Copyright 2023 The Casdoor Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import i18next from "i18next";
import {createButton} from "react-social-login-buttons";
import {StaticBaseUrl} from "../Setting";
function LoginButton({type, align = "center", style = {background: "#ffffff", color: "#000000"}, activeStyle = {background: "#ededee"}}) {
function Icon({width = 24, height = 24, color}) {
return <img src={`${StaticBaseUrl}/buttons/${type.toLowerCase()}.svg`} alt={`Sign in with ${type}`} style={{width: width, height: height}} />;
}
const config = {
text: `Sign in with ${type}`,
icon: Icon,
style: style,
activeStyle: activeStyle,
};
const Button = createButton(config);
const text = i18next.t("login:Sign in with {type}").replace("{type}", type);
return <Button text={text} align={align} />;
}
export default LoginButton;

View File

@ -125,6 +125,198 @@ const authInfo = {
scope: "profile%20openid%20email",
endpoint: "https://access.line.me/oauth2/v2.1/authorize",
},
Amazon: {
scope: "profile",
endpoint: "https://www.amazon.com/ap/oa",
},
Auth0: {
scope: "openid%20profile%20email",
endpoint: "http://auth0.com/authorize",
},
BattleNet: {
scope: "openid",
endpoint: "https://oauth.battlenet.com.cn/authorize",
},
Bitbucket: {
scope: "account",
endpoint: "https://bitbucket.org/site/oauth2/authorize",
},
Box: {
scope: "root_readwrite",
endpoint: "https://account.box.com/api/oauth2/authorize",
},
CloudFoundry: {
scope: "cloud_controller.read",
endpoint: "https://login.cloudfoundry.org/oauth/authorize",
},
Dailymotion: {
scope: "userinfo",
endpoint: "https://api.dailymotion.com/oauth/authorize",
},
Deezer: {
scope: "basic_access",
endpoint: "https://connect.deezer.com/oauth/auth.php",
},
DigitalOcean: {
scope: "read",
endpoint: "https://cloud.digitalocean.com/v1/oauth/authorize",
},
Discord: {
scope: "identify%20email",
endpoint: "https://discord.com/api/oauth2/authorize",
},
Dropbox: {
scope: "account_info.read",
endpoint: "https://www.dropbox.com/oauth2/authorize",
},
EveOnline: {
scope: "publicData",
endpoint: "https://login.eveonline.com/oauth/authorize",
},
Fitbit: {
scope: "activity%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight",
endpoint: "https://www.fitbit.com/oauth2/authorize",
},
Gitea: {
scope: "user:email",
endpoint: "https://gitea.com/login/oauth/authorize",
},
Heroku: {
scope: "global",
endpoint: "https://id.heroku.com/oauth/authorize",
},
InfluxCloud: {
scope: "read:org",
endpoint: "https://cloud2.influxdata.com/oauth/authorize",
},
Instagram: {
scope: "user_profile",
endpoint: "https://api.instagram.com/oauth/authorize",
},
Intercom: {
scope: "user.read",
endpoint: "https://app.intercom.com/oauth",
},
Kakao: {
scope: "account_email",
endpoint: "https://kauth.kakao.com/oauth/authorize",
},
Lastfm: {
scope: "user_read",
endpoint: "https://www.last.fm/api/auth",
},
Mailru: {
scope: "userinfo",
endpoint: "https://oauth.mail.ru/login",
},
Meetup: {
scope: "basic",
endpoint: "https://secure.meetup.com/oauth2/authorize",
},
MicrosoftOnline: {
scope: "openid%20profile%20email",
endpoint: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
},
Naver: {
scope: "profile",
endpoint: "https://nid.naver.com/oauth2.0/authorize",
},
Nextcloud: {
scope: "openid%20profile%20email",
endpoint: "https://cloud.example.org/apps/oauth2/authorize",
},
OneDrive: {
scope: "offline_access%20onedrive.readonly",
endpoint: "https://login.live.com/oauth20_authorize.srf",
},
Oura: {
scope: "personal",
endpoint: "https://cloud.ouraring.com/oauth/authorize",
},
Patreon: {
scope: "identity",
endpoint: "https://www.patreon.com/oauth2/authorize",
},
Paypal: {
scope: "openid%20profile%20email",
endpoint: "https://www.sandbox.paypal.com/connect",
},
SalesForce: {
scope: "openid%20profile%20email",
endpoint: "https://login.salesforce.com/services/oauth2/authorize",
},
Shopify: {
scope: "read_products",
endpoint: "https://myshopify.com/admin/oauth/authorize",
},
Soundcloud: {
scope: "non-expiring",
endpoint: "https://api.soundcloud.com/connect",
},
Spotify: {
scope: "user-read-email",
endpoint: "https://accounts.spotify.com/authorize",
},
Strava: {
scope: "read",
endpoint: "https://www.strava.com/oauth/authorize",
},
Stripe: {
scope: "read_only",
endpoint: "https://connect.stripe.com/oauth/authorize",
},
TikTok: {
scope: "user.info.basic",
endpoint: "https://www.tiktok.com/auth/authorize/",
},
Tumblr: {
scope: "email",
endpoint: "https://www.tumblr.com/oauth2/authorize",
},
Twitch: {
scope: "user_read",
endpoint: "https://id.twitch.tv/oauth2/authorize",
},
Twitter: {
scope: "users.read",
endpoint: "https://twitter.com/i/oauth2/authorize",
},
Typetalk: {
scope: "my",
endpoint: "https://typetalk.com/oauth2/authorize",
},
Uber: {
scope: "profile",
endpoint: "https://login.uber.com/oauth/v2/authorize",
},
VK: {
scope: "email",
endpoint: "https://oauth.vk.com/authorize",
},
Wepay: {
scope: "manage_accounts%20view_user",
endpoint: "https://www.wepay.com/v2/oauth2/authorize",
},
Xero: {
scope: "openid%20profile%20email",
endpoint: "https://login.xero.com/identity/connect/authorize",
},
Yahoo: {
scope: "openid%20profile%20email",
endpoint: "https://api.login.yahoo.com/oauth2/request_auth",
},
Yammer: {
scope: "user",
endpoint: "https://www.yammer.com/oauth2/authorize",
},
Yandex: {
scope: "login:email",
endpoint: "https://oauth.yandex.com/authorize",
},
Zoom: {
scope: "user:read",
endpoint: "https://zoom.us/oauth/authorize",
},
};
export function getProviderUrl(provider) {
@ -184,12 +376,19 @@ export function getAuthUrl(application, provider, method) {
const isShortState = provider.type === "WeChat" && navigator.userAgent.includes("MicroMessenger");
const state = Util.getStateFromQueryParams(application.name, provider.name, method, isShortState);
const codeChallenge = "P3S-a7dr8bgM4bF6vOyiKkKETDl16rcAzao9F8UIL1Y"; // SHA256(Base64-URL-encode("casdoor-verifier"))
if (provider.type === "Google") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "GitHub") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "QQ") {
if (provider.type === "Google" || provider.type === "GitHub" || provider.type === "QQ" || provider.type === "Facebook" || provider.type === "DingTalk"
|| provider.type === "Weibo" || provider.type === "Gitee" || provider.type === "LinkedIn" || provider.type === "GitLab" || provider.type === "AzureAD"
|| provider.type === "Slack" || provider.type === "Line" || provider.type === "Amazon" || provider.type === "Auth0" || provider.type === "BattleNet"
|| provider.type === "Bitbucket" || provider.type === "Box" || provider.type === "CloudFoundry" || provider.type === "Dailymotion"
|| provider.type === "DigitalOcean" || provider.type === "Discord" || provider.type === "Dropbox" || provider.type === "EveOnline" || provider.type === "Gitea"
|| provider.type === "Heroku" || provider.type === "InfluxCloud" || provider.type === "Instagram" || provider.type === "Intercom" || provider.type === "Kakao"
|| provider.type === "MailRu" || provider.type === "Meetup" || provider.type === "MicrosoftOnline" || provider.type === "Naver" || provider.type === "Nextcloud"
|| provider.type === "OneDrive" || provider.type === "Oura" || provider.type === "Patreon" || provider.type === "PayPal" || provider.type === "SalesForce"
|| provider.type === "SoundCloud" || provider.type === "Spotify" || provider.type === "Strava" || provider.type === "Stripe" || provider.type === "Tumblr"
|| provider.type === "Twitch" || provider.type === "Typetalk" || provider.type === "Uber" || provider.type === "VK" || provider.type === "Wepay"
|| provider.type === "Xero" || provider.type === "Yahoo" || provider.type === "Yammer" || provider.type === "Yandex" || provider.type === "Zoom") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "WeChat") {
if (navigator.userAgent.includes("MicroMessenger")) {
@ -197,16 +396,6 @@ export function getAuthUrl(application, provider, method) {
} else {
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}#wechat_redirect`;
}
} else if (provider.type === "Facebook") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "DingTalk") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}&prompt=consent`;
} else if (provider.type === "Weibo") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "Gitee") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "LinkedIn") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
} else if (provider.type === "WeCom") {
if (provider.subType === "Internal") {
if (provider.method === "Silent") {
@ -232,8 +421,6 @@ export function getAuthUrl(application, provider, method) {
}
} else if (provider.type === "Lark") {
return `${endpoint}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}`;
} else if (provider.type === "GitLab") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Adfs") {
return `${provider.domain}/adfs/oauth2/authorize?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&nonce=casdoor&scope=openid`;
} else if (provider.type === "Baidu") {
@ -246,21 +433,23 @@ export function getAuthUrl(application, provider, method) {
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}?state=${state}`;
} else if (provider.type === "Apple") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&response_mode=form_post`;
} else if (provider.type === "AzureAD") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Slack") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Steam") {
return `${endpoint}?openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.realm=${window.location.origin}&openid.return_to=${redirectUri}?state=${state}`;
} else if (provider.type === "Okta") {
return `${provider.domain}/v1/authorize?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Douyin") {
} else if (provider.type === "Douyin" || provider.type === "TikTok") {
return `${endpoint}?client_key=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Custom") {
return `${provider.customAuthUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${provider.customScope}&response_type=code&state=${state}`;
} else if (provider.type === "Bilibili") {
return `${endpoint}#/?client_id=${provider.clientId}&return_url=${redirectUri}&state=${state}&response_type=code`;
} else if (provider.type === "Line") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
} else if (provider.type === "Deezer") {
return `${endpoint}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&perms=${scope}`;
} else if (provider.type === "Lastfm") {
return `${endpoint}?api_key=${provider.clientId}&cb=${redirectUri}`;
} else if (provider.type === "Shopify") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&state=${state}&grant_options[]=per-user`;
} else if (provider.type === "Twitter" || provider.type === "Fitbit") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&code_challenge=${codeChallenge}&code_challenge_method=S256`;
}
}

View File

@ -39,7 +39,7 @@ import SteamLoginButton from "./SteamLoginButton";
import BilibiliLoginButton from "./BilibiliLoginButton";
import OktaLoginButton from "./OktaLoginButton";
import DouyinLoginButton from "./DouyinLoginButton";
import LineLoginButton from "./LineLoginButton";
import LoginButton from "./LoginButton";
import * as AuthBackend from "./AuthBackend";
import {getEvent} from "./Util";
import {Modal} from "antd";
@ -94,11 +94,9 @@ function getSigninButton(type) {
return <OktaLoginButton text={text} align={"center"} />;
} else if (type === "Douyin") {
return <DouyinLoginButton text={text} align={"center"} />;
} else if (type === "Line") {
return <LineLoginButton text={text} align={"center"} />;
} else {
return <LoginButton key={type} type={type} />;
}
return text;
}
function getSamlUrl(provider, location) {