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

Salesforce social login #4819

Merged
merged 5 commits into from Jan 19, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -24,3 +24,11 @@ e.g. Social Login Key
- **Client Secret** : `123456`
- **Enable Social Login** : `Check`
- **Base URL** : `https://erpnext.org` (required for some providers)

#### Generating Client ID and Client Secret for providers

- <a href="https://developers.google.com/identity/sign-in/web/devconsole-project">Creating a Google API Console project and client ID</a>
- <a href="https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow">Manually Build a Login Flow for Facebook</a>
- <a href="https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/">Creating an OAuth App for GitHub</a>
- <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-openid-connect-code">Authorize access to web applications using OpenID Connect and Azure Active Directory</a>
- <a href="https://help.salesforce.com/articleView?id=connected_app_create.htm">Create a Connected App on Salesforce</a>
@@ -93,7 +93,7 @@
"label": "Social Login Provider",
"length": 0,
"no_copy": 0,
"options": "Custom\nFacebook\nFrappe\nGitHub\nGoogle\nOffice 365",
"options": "Custom\nFacebook\nFrappe\nGitHub\nGoogle\nOffice 365\nSalesforce",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -660,7 +660,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2017-12-21 13:55:17.041059",
"modified": "2018-01-13 21:19:37.800121",
"modified_by": "Administrator",
"module": "Integrations",
"name": "Social Login Key",
@@ -120,6 +120,23 @@ def get_social_login_provider(self, provider, initialize=False):
})
}

providers["Salesforce"] = {
"provider_name": "Salesforce",
"enable_social_login": 1,
"base_url": "https://login.salesforce.com",
"custom_base_url": 0,
"icon":"fa fa-cloud", #https://github.com/FortAwesome/Font-Awesome/issues/1744
"redirect_url": "/api/method/frappe.integrations.oauth2_logins.login_via_salesforce",
"api_endpoint": "https://login.salesforce.com/services/oauth2/userinfo",
"api_endpoint_args":None,
"authorize_url": "https://login.salesforce.com/services/oauth2/authorize",
"access_token_url": "https://login.salesforce.com/services/oauth2/token",
"auth_url_data": json.dumps({
"response_type": "code",
"scope": "openid"
})
}

# Initialize the doc and return, used in patch
# Or can be used for creating key from controller
if initialize and provider:
@@ -26,3 +26,7 @@ def login_via_frappe(code, state):
@frappe.whitelist(allow_guest=True)
def login_via_office365(code, state):
login_via_oauth2_id_token("office_365", code, state, decoder=json.loads)

@frappe.whitelist(allow_guest=True)
def login_via_salesforce(code, state):
login_via_oauth2("salesforce", code, state, decoder=json.loads)
@@ -262,6 +262,10 @@ def update_oauth_user(user, data, provider):
save = True
user.set_social_login_userid(provider, userid=data["sub"])

elif provider=="salesforce" and not user.get_social_login_userid(provider):
save = True
user.set_social_login_userid(provider, userid="/".join(data["sub"].split("/")[-2:]))

if save:
user.flags.ignore_permissions = True
user.flags.no_welcome_mail = True
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.