Skip to content

feat: generate redirect to automatically#303

Merged
neilLasrado merged 12 commits intoBloomstack:developfrom
hrwX:OAuth_redirect_autocreate
Nov 16, 2020
Merged

feat: generate redirect to automatically#303
neilLasrado merged 12 commits intoBloomstack:developfrom
hrwX:OAuth_redirect_autocreate

Conversation

@hrwX
Copy link
Copy Markdown

@hrwX hrwX commented Oct 30, 2020

Comment thread frappe/integrations/oauth2_logins.py Outdated
@frappe.whitelist(allow_guest=True)
def get_login_url(redirect_to=None, social_login_key_name="bloomstack"):

if not redirect_to and frappe.get_cached_value("OAuth Client", {"app_name": "Bloomstack"}, "client_id") and frappe.get_hooks("bloomstack_redirect_uri"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hrwX App name will be Frappe for this one.

Comment thread frappe/integrations/oauth2_logins.py Outdated
if not redirect_to and frappe.get_cached_value("OAuth Client", {"app_name": "Bloomstack"}, "client_id") and frappe.get_hooks("bloomstack_redirect_uri"):
redirect_to = "{0}/api/method/frappe.integrations.oauth2.authorize?client_id={1}&response_type=code&scope=openid&prompt=none& \
redirect_uri={2}".format(frappe.utils.get_url(), frappe.get_cached_value("OAuth Client", {"app_name": "Bloomstack"}, "client_id"),
frappe.get_hooks("bloomstack_redirect_uri"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hrwX sorry I just realized that OAuth Client doctype already has a Redirect URL which is something we can use.
Ref: https://demo.bloomstack.garden/desk#Form/OAuth%20Client/b0356dedd8

Comment thread frappe/integrations/oauth2_logins.py Outdated
client = frappe.get_cached_doc("OAuth Client", {"app_name": "Frappe"})
if not redirect_to and client:
redirect_to = "{0}/api/method/frappe.integrations.oauth2.authorize?client_id={1}&response_type=code&scope=openid&prompt=none& \
redirect_uri={2}".format(frappe.utils.get_url(), client.get("client_id"), client.get("redirect_uris"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better would be to use default redirect URI as the user can define multiple URLs in redirect URIs.

@neilLasrado neilLasrado merged commit 0023a58 into Bloomstack:develop Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants