diff --git a/app/developer/__init__.py b/app/developer/__init__.py index 0a204cef..c875a5ee 100644 --- a/app/developer/__init__.py +++ b/app/developer/__init__.py @@ -1 +1 @@ -from .views import index, new_client, client_detail +from .views import index, new_client, client_detail, step diff --git a/app/developer/templates/developer/steps/step-0.html b/app/developer/templates/developer/steps/step-0.html new file mode 100644 index 00000000..172d1678 --- /dev/null +++ b/app/developer/templates/developer/steps/step-0.html @@ -0,0 +1,47 @@ +{% extends 'default.html' %} + +{% set active_page = "developer" %} + +{% block title %} + Step 1: Add SimpleLogin button +{% endblock %} + +{% block default_content %} +

Step 1: Add SimpleLogin button

+ +
+

The first step is to add the SimpleLogin button onto your website/application.

+

+ SimpleLogin does not impose any hard guideline on the button color, font, etc + but gives rather some recommendations on + Styling Guide +

+ +
+ + + I have access to my back-end (Python, NodeJS, Php, etc) + + + +
OR
+ + + I do not have access to my back-end, my app is a SPA(Single-page application) or a mobile app. + + + +
OR
+ + + I know what I need, just bring me to the app detail page 😎 + +
+ + +{% endblock %} diff --git a/app/developer/templates/developer/steps/step-authorization-flow.html b/app/developer/templates/developer/steps/step-authorization-flow.html new file mode 100644 index 00000000..d399dc55 --- /dev/null +++ b/app/developer/templates/developer/steps/step-authorization-flow.html @@ -0,0 +1,122 @@ +{% extends 'default.html' %} + +{% set active_page = "developer" %} + +{% block title %} + Step 2: Integrate SimpleLogin using OAuth2/OpenID +{% endblock %} + +{% block default_content %} +
+

Step 2: Integrate SimpleLogin using OAuth2/OpenID

+

+ SimpleLogin will be integrated into your app using + + OAuth2 Authorization Code + flow. +

+ +

+ For more details on this flow, please consult our doc on: + + Backend Integration + +

+ +

And if you already know this flow, here are the OAuth2 endpoints:

+ +

+ Authorization endpoint: + https://app.simplelogin.io/oauth2/authorize + +

+ +

+ Token endpoint: + https://app.simplelogin.io/oauth2/token + +

+ +

+ UserInfo endpoint: + https://app.simplelogin.io/oauth2/userinfo + +

+ + Please find below your OAuth Client-Id and Client-Secret that are needed for the Authorization Code Flow: +
+ +
+ + +
+ + + + +
+
+ +
+ + +
+ + + + +
+
+ +

+ By default, SimpleLogin whitelists localhost address that should facilitate the local development. +

+ +

+ We have created some examples along with a step-by-step guide on some framework/libraries, + feel free to check them out: +
+ + PassportJS (NodeJS) + +
+ Requests-OAuthlib + (Python) + +

+ + Once you finished SimpleLogin integration, do not forget to add your website as valid redirect_uri + on the app detail page 😀
+ + + App detail page + + +
+ + +{% endblock %} + +{% block script %} + +{% endblock %} \ No newline at end of file diff --git a/app/developer/templates/developer/steps/step-implicit-flow.html b/app/developer/templates/developer/steps/step-implicit-flow.html new file mode 100644 index 00000000..121d0fae --- /dev/null +++ b/app/developer/templates/developer/steps/step-implicit-flow.html @@ -0,0 +1,83 @@ +{% extends 'default.html' %} + +{% set active_page = "developer" %} + +{% block title %} + Step 2: Integrate SimpleLogin using OAuth2/OpenID +{% endblock %} + +{% block default_content %} +
+

Step 2: Integrate SimpleLogin using OAuth2/OpenID

+

SimpleLogin will be integrated into your app using + OAuth 2.0 Implicit Grant flow. +

+ +

+ For more details on this flow, please consult our doc on: + Frontend Integration +

+ +

And if you already know this flow, here are the corresponding endpoints:

+ +

+ Authorization endpoint: + https://app.simplelogin.io/oauth2/authorize + +

+ +

+ UserInfo endpoint: + https://app.simplelogin.io/oauth2/userinfo + +

+ + Please find below your OAuth Client-Id that is needed for the Implicit Flow +
+ +
+ + +
+ + + + +
+
+ +

+ By default, SimpleLogin whitelists localhost address that should facilitate the local development. +

+ + Once you finished SimpleLogin integration, do not forget to add your website as valid redirect_uri + on the app detail page 😀
+ + + App detail page + + +
+ + +{% endblock %} + +{% block script %} + +{% endblock %} \ No newline at end of file diff --git a/app/developer/views/step.py b/app/developer/views/step.py new file mode 100644 index 00000000..d5b9e6f4 --- /dev/null +++ b/app/developer/views/step.py @@ -0,0 +1,23 @@ +"""Onboarding for developer when creating new app""" +from flask import render_template, flash, redirect, url_for +from flask_login import login_required, current_user + +from app.developer.base import developer_bp +from app.models import Client + + +@developer_bp.route("/client//") +@login_required +def handle_step(client_id, step): + client = Client.get(client_id) + if not client: + flash("no such client", "warning") + return redirect(url_for("developer.index")) + + if client.user_id != current_user.id: + flash("you cannot see this client", "warning") + return redirect(url_for("developer.index")) + + return render_template( + f"developer/steps/{step}.html", client_id=client_id, client=client + )