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

New OAuth login page #391

Open
wants to merge 79 commits into
base: new-oauth
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
a33da6f
Initial OAuth Work commit
amCap1712 Jul 28, 2021
e0bda64
Add CodeChallenge extension to authorization code flow
amCap1712 Jul 29, 2021
e628c59
Add ImplicitGrant
amCap1712 Jul 29, 2021
88f773a
Add RefreshTokenGrant
amCap1712 Jul 29, 2021
53d5c13
Add revocation endpoint
amCap1712 Jul 31, 2021
847f054
second commit
amCap1712 Oct 6, 2022
2f34f15
Update models
amCap1712 Oct 6, 2022
eeee36a
misc updates
amCap1712 Oct 6, 2022
015775b
update authlib and implementation
amCap1712 Oct 6, 2022
94fdd52
more updates
amCap1712 Oct 6, 2022
0bd7f36
misc fixes
amCap1712 Oct 6, 2022
f1ee278
misc fixes - 2
amCap1712 Oct 6, 2022
7cdc3f1
add introspection endpoint
amCap1712 Oct 7, 2022
27146a9
fix return
amCap1712 Oct 7, 2022
5115adf
fix bugs
amCap1712 Oct 7, 2022
3ba4519
Create dummy oauth."user" table
amCap1712 May 9, 2023
d44838a
temp fix for create_tables oauth
amCap1712 May 10, 2023
86ace6a
fix before_first_request
amCap1712 May 11, 2023
f54acb7
fix before_first_request -2
amCap1712 May 11, 2023
df56e67
Create new OAuth login page
MonkeyDo Oct 6, 2022
70738ad
Use more generic css class names
MonkeyDo May 11, 2023
ac76d5c
Add initial signup page
MonkeyDo May 11, 2023
abcb376
Small improvements of the signup page
MonkeyDo May 11, 2023
e0a443c
Bigger TOC modal
MonkeyDo May 11, 2023
511e3b6
Improve login/signup logos
MonkeyDo May 11, 2023
3cb6eae
Change sign in page header
MonkeyDo May 12, 2023
d688a33
fix ISEs and oauth setup
amCap1712 May 17, 2023
8ec86c5
Create new OAuth login page
MonkeyDo Oct 6, 2022
7a0ee23
Use more generic css class names
MonkeyDo May 11, 2023
02c9715
Add initial signup page
MonkeyDo May 11, 2023
a5b5b50
Small improvements of the signup page
MonkeyDo May 11, 2023
5e4663d
Bigger TOC modal
MonkeyDo May 11, 2023
e3e6851
Improve login/signup logos
MonkeyDo May 11, 2023
34af6be
Change sign in page header
MonkeyDo May 12, 2023
9a6c0c2
Merge branch 'new-login-page' of https://github.com/metabrainz/metabr…
MonkeyDo May 31, 2023
994507a
Bump jinja2 from 3.1.2 to 3.1.3
dependabot[bot] Jan 11, 2024
1a66f8f
Merge pull request #454 from metabrainz/dependabot/pip/jinja2-3.1.3
mayhem Jan 12, 2024
d751dc3
general updates: remove freso, adjust simon and reo's titles. Move
mayhem Mar 1, 2024
563145a
Merge pull request #455 from metabrainz/update-team-page
mayhem Mar 1, 2024
28b4cc5
Add Hazel Savage as our director.
mayhem Mar 6, 2024
3189f9a
Merge pull request #456 from metabrainz/add-hazel
mayhem Mar 6, 2024
a6b7d43
Follow updating Bluesky handle with our domain (#457)
yvanzo Mar 18, 2024
0cdae65
Update dependencies
amCap1712 Mar 20, 2024
01e3125
Move user templates to supporters directory
amCap1712 Mar 20, 2024
71c690d
Rename ProfileEdit.tsx to SupporterProfileEdit.tsx
amCap1712 Mar 20, 2024
246a8b7
Make EUR donations go to USD paypal account.
mayhem Mar 27, 2024
fd19923
Merge pull request #460 from metabrainz/fix-eur-donations
mayhem Mar 27, 2024
bd438fc
Add docs for Q1
mayhem Apr 4, 2024
d1073d8
Find the highest invoice number and then manually assign the invoice
mayhem Apr 5, 2024
ba81f16
Merge pull request #461 from metabrainz/fix-invoice-number-assignment
mayhem Apr 5, 2024
fb9d2bf
Bump idna from 3.6 to 3.7
dependabot[bot] Apr 12, 2024
126f9be
Merge pull request #462 from metabrainz/dependabot/pip/idna-3.7
mayhem Apr 12, 2024
8a70848
Dataset 'crate' logo images
Aerozol Apr 27, 2024
c0c645d
Bump werkzeug from 3.0.1 to 3.0.3
dependabot[bot] May 6, 2024
e191106
Bump jinja2 from 3.1.3 to 3.1.4
dependabot[bot] May 6, 2024
ffa6383
Merge pull request #463 from Aerozol/master
mayhem May 8, 2024
8cabe67
Merge pull request #464 from metabrainz/dependabot/pip/werkzeug-3.0.3
mayhem May 8, 2024
5ddec5f
Merge pull request #465 from metabrainz/dependabot/pip/jinja2-3.1.4
mayhem May 8, 2024
f9b97a3
---
dependabot[bot] May 21, 2024
32732e9
Merge pull request #466 from metabrainz/dependabot/pip/requests-2.32.0
mayhem May 21, 2024
938b67d
Bump urllib3 from 2.2.1 to 2.2.2
dependabot[bot] Jun 17, 2024
d4a4237
Merge pull request #467 from metabrainz/dependabot/pip/urllib3-2.2.2
mayhem Jun 18, 2024
6399d02
Bump braces from 3.0.2 to 3.0.3
dependabot[bot] Jun 18, 2024
6b1532b
Merge pull request #468 from metabrainz/dependabot/npm_and_yarn/brace…
mayhem Jun 18, 2024
8e6d98b
Update import scripts again
mayhem Jul 2, 2024
f4278ea
Update financial reports
mayhem Jul 2, 2024
4a8d5cf
Fix logging stripe one time charge transactions (#469)
amCap1712 Jul 15, 2024
14c3a09
Support EUR payments in stripe
amCap1712 Jul 16, 2024
8bfe6c2
Improve wording on the payment page
mayhem Jul 16, 2024
de2866e
Fix payments page for stripe eur payments
amCap1712 Jul 16, 2024
3c75a81
Remove paypal buttons from donation and payment page
amCap1712 Jul 16, 2024
661cc31
Fix currency for stripe payments
amCap1712 Jul 16, 2024
0be8f6d
Update the address on donation receipts
mayhem Jul 16, 2024
5795778
Update sentry sdk (#474)
mayhem Jul 23, 2024
eaf7f9d
MEB-163: Update the docs for cancelling payments
reosarevok Aug 29, 2024
08aefe6
remove explicit mbdata dependency
amCap1712 Aug 30, 2024
82bf0c0
Bump webpack from 5.88.1 to 5.94.0
dependabot[bot] Aug 30, 2024
e1e3844
Merge branch 'master' into new-login-page
MonkeyDo Aug 30, 2024
0437fc1
Clarify signup page text
MonkeyDo Aug 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions admin/sql/oauth/create_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
CREATE TABLE oauth."user" (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
name TEXT NOT NULL,
email TEXT,
unconfirmed_email TEXT,
website TEXT,
member_since TIMESTAMP WITH TIME ZONE,
email_confirm_date TIMESTAMP WITH TIME ZONE,
last_login_date TIMESTAMP WITH TIME ZONE,
last_updated TIMESTAMP WITH TIME ZONE,
birth_date DATE,
gender INTEGER,
password TEXT NOT NULL,
ha1 TEXT NOT NULL,
deleted BOOLEAN,
PRIMARY KEY (id)
);



CREATE TABLE oauth.scope (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
name TEXT NOT NULL,
description TEXT NOT NULL,
PRIMARY KEY (id)
);



CREATE TABLE oauth.client (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
client_id TEXT NOT NULL,
client_secret TEXT,
owner_id INTEGER NOT NULL,
name TEXT NOT NULL,
description TEXT NOT NULL,
website TEXT,
redirect_uris TEXT[] NOT NULL,
client_id_issued_at TIMESTAMP WITH TIME ZONE NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(owner_id) REFERENCES oauth."user" (id) ON DELETE CASCADE
);


CREATE TABLE oauth.code (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
user_id INTEGER NOT NULL,
client_id INTEGER NOT NULL,
code TEXT NOT NULL,
redirect_uri TEXT NOT NULL,
response_type TEXT NOT NULL,
code_challenge TEXT,
code_challenge_method TEXT,
granted_at TIMESTAMP WITH TIME ZONE NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(user_id) REFERENCES oauth."user" (id) ON DELETE CASCADE,
FOREIGN KEY(client_id) REFERENCES oauth.client (id) ON DELETE CASCADE,
UNIQUE (code)
);


CREATE TABLE oauth.token (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
user_id INTEGER NOT NULL,
client_id INTEGER NOT NULL,
access_token TEXT NOT NULL,
refresh_token TEXT,
issued_at TIMESTAMP WITH TIME ZONE,
expires_in INTEGER,
revoked BOOLEAN,
PRIMARY KEY (id),
FOREIGN KEY(user_id) REFERENCES oauth."user" (id) ON DELETE CASCADE,
FOREIGN KEY(client_id) REFERENCES oauth.client (id) ON DELETE CASCADE,
UNIQUE (access_token)
);


CREATE INDEX ix_oauth_token_refresh_token ON oauth.token (refresh_token);

CREATE TABLE oauth.l_token_scope (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
token_id INTEGER NOT NULL,
scope_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(token_id) REFERENCES oauth.token (id) ON DELETE CASCADE,
FOREIGN KEY(scope_id) REFERENCES oauth.scope (id) ON DELETE CASCADE
);

CREATE TABLE oauth.l_code_scope (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
code_id INTEGER NOT NULL,
scope_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(code_id) REFERENCES oauth.code (id) ON DELETE CASCADE,
FOREIGN KEY(scope_id) REFERENCES oauth.scope (id) ON DELETE CASCADE
);
13 changes: 10 additions & 3 deletions config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ PAYPAL_BUSINESS = "[email protected]"
# Stripe
# https://stripe.com/docs/tutorials/dashboard#api-keys
STRIPE_KEYS = {
"SECRET": "",
"PUBLISHABLE": "",
"WEBHOOK_SECRET": ""
"USD": {
"SECRET": "",
"PUBLISHABLE": "",
"WEBHOOK_SECRET": ""
},
"EUR": {
"SECRET": "",
"PUBLISHABLE": "",
"WEBHOOK_SECRET": ""
}
}

# if developing payment integration locally, change this to your localhost url
Expand Down
13 changes: 10 additions & 3 deletions consul_config.py.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ PAYPAL_ACCOUNT_IDS = {
PAYPAL_BUSINESS = '''{{template "KEY" "payments/paypal/business_email"}}'''

STRIPE_KEYS = {
"SECRET": '''{{template "KEY" "payments/stripe/secret"}}''',
"PUBLISHABLE": '''{{template "KEY" "payments/stripe/publishable"}}''',
"WEBHOOK_SECRET": '''{{template "KEY" "payments/stripe/webhook_secret"}}''',
"USD": {
"SECRET": '''{{template "KEY" "payments/stripe/secret"}}''',
"PUBLISHABLE": '''{{template "KEY" "payments/stripe/publishable"}}''',
"WEBHOOK_SECRET": '''{{template "KEY" "payments/stripe/webhook_secret"}}''',
},
"EUR": {
"SECRET": '''{{template "KEY" "payments/stripe-eu/secret"}}''',
"PUBLISHABLE": '''{{template "KEY" "payments/stripe-eu/publishable"}}''',
"WEBHOOK_SECRET": '''{{template "KEY" "payments/stripe-eu/webhook_secret"}}''',
},
}

# MusicBrainz Base URL must have a trailing slash.
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ services:
dockerfile: Dockerfile
target: metabrainz-dev
command: python manage.py runserver -h 0.0.0.0 -p 80
environment:
AUTHLIB_INSECURE_TRANSPORT: true
volumes:
- ../data/replication_packets:/data/replication_packets
- ../data/json_dumps:/data/json_dumps
Expand Down
72 changes: 72 additions & 0 deletions frontend/css/auth-page.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#auth-page {

font-style: normal;
font-weight: 400;
min-height: 500px;
background: linear-gradient(90deg, #3B9766 0%, #FFA500 100%);
margin: 0 -1em;
padding: 2em;

.form-label{
font-weight: normal;
}

.icon-pills {
display: flex;
justify-content: space-evenly;
margin-bottom: 2rem;
}
.icon-pill {
background: #D9D9D9;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
border-radius: 50%;
text-align: center;
width:50px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
img {
width:65%;
}
}

.auth-page-container {
max-width: 400px;
margin-left: auto;
margin-right: auto;
}
.auth-card-container {
background: #E7E7E7;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
border-radius: 3px;
}
.auth-card {
h1,h2,h3,h4,h5,h6{
font-weight: bold;
}
background: #FFFFFF;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
padding: 1rem;
border-radius: 3px;
}
.auth-card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.auth-card-footer {
padding: 1rem;
font-size: 1.3rem;
line-height: 1.6rem;
color: #808080;
}
.main-action-button {
display: block;
font-size: 1.1em;
margin: 1em auto;
}
.modal-content {
padding:1.5em;
}
}
1 change: 1 addition & 0 deletions frontend/css/main.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "theme/theme.less";
@import "carousel.less";
@import "auth-page.less";

@icon-font-path:"/static/fonts/";

Expand Down
2 changes: 1 addition & 1 deletion frontend/css/theme/boostrap/boostrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
//@import "close.less";

// Components w/ JavaScript
//@import "modals.less";
@import "modals.less";
@import "tooltip.less";
//@import "popovers.less";
@import "carousel.less";
Expand Down
Binary file added frontend/img/projects/critiquebrainz-crate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/img/projects/listenbrainz-crate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/img/projects/musicbrainz-crate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import * as Yup from "yup";
import { getPageProps } from "../utils";
import { Dataset, DatasetsInput, TextInput } from "./utils";

type ProfileEditProps = {
type SupporterProfileEditProps = {
datasets: Dataset[];
is_commercial: boolean;
csrf_token: string;
initial_form_data: any;
initial_errors: any;
};

function ProfileEdit({
function SupporterProfileEdit({
datasets,
is_commercial,
csrf_token,
initial_form_data,
initial_errors,
}: ProfileEditProps): JSX.Element {
}: SupporterProfileEditProps): JSX.Element {
return (
<>
<h1 className="page-title">Your Profile</h1>
Expand Down Expand Up @@ -104,7 +104,7 @@ document.addEventListener("DOMContentLoaded", () => {

const renderRoot = createRoot(domContainer!);
renderRoot.render(
<ProfileEdit
<SupporterProfileEdit
datasets={datasets}
is_commercial={is_commercial}
csrf_token={csrf_token}
Expand Down
29 changes: 25 additions & 4 deletions metabrainz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
from metabrainz.admin.quickbooks.views import QuickBooksView
from time import sleep

from metabrainz.new_oauth.authorization_grant import AuthorizationCodeGrant
from metabrainz.new_oauth.provider import authorization_server, revoke_token

from authlib.oauth2.rfc6749 import ImplicitGrant
from authlib.oauth2.rfc7636 import CodeChallenge

from metabrainz.new_oauth.authorization_grant import AuthorizationCodeGrant
from metabrainz.new_oauth.refresh_grant import RefreshTokenGrant

from metabrainz.utils import get_global_props

# Check to see if we're running under a docker deployment. If so, don't second guess
Expand Down Expand Up @@ -51,10 +60,10 @@ def create_app(debug=None, config_path=None):
'..', 'config.py'
))

# Load configuration files: If we're running under a docker deployment, wait until
# Load configuration files: If we're running under a docker deployment, wait until
# the consul configuration is available.
if deploy_env:
consul_config = os.path.join( os.path.dirname(os.path.realpath(__file__)),
consul_config = os.path.join( os.path.dirname(os.path.realpath(__file__)),
'..', 'consul_config.py')

print("loading consul %s" % consul_config)
Expand Down Expand Up @@ -132,6 +141,8 @@ def create_app(debug=None, config_path=None):
LOGO_UPLOAD_SET,
])

config_oauth(app)

# Blueprints
_register_blueprints(app)

Expand Down Expand Up @@ -169,8 +180,6 @@ def create_app(debug=None, config_path=None):
if app.config["QUICKBOOKS_CLIENT_ID"]:
admin.add_view(QuickBooksView(name='Invoices', endpoint="quickbooks/", category='Quickbooks'))

stripe.api_key = app.config["STRIPE_KEYS"]["SECRET"]

return app


Expand Down Expand Up @@ -206,9 +215,21 @@ def _register_blueprints(app):

from metabrainz.oauth.views import oauth_bp
app.register_blueprint(oauth_bp, url_prefix='/oauth')
from metabrainz.new_oauth.views import new_oauth_bp
app.register_blueprint(new_oauth_bp, url_prefix='/new-oauth')
from metabrainz.api.views.index import api_index_bp
app.register_blueprint(api_index_bp, url_prefix='/api')
from metabrainz.api.views.supporter import api_supporter_bp
app.register_blueprint(api_supporter_bp, url_prefix='/api/supporter')
from metabrainz.api.views.musicbrainz import api_musicbrainz_bp
app.register_blueprint(api_musicbrainz_bp, url_prefix='/api/musicbrainz')


def config_oauth(app):
authorization_server.init_app(app)

authorization_server.register_grant(AuthorizationCodeGrant, [CodeChallenge(required=False)])
authorization_server.register_grant(ImplicitGrant)
authorization_server.register_grant(RefreshTokenGrant)
authorization_server.register_endpoint(revoke_token)

2 changes: 1 addition & 1 deletion metabrainz/admin/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import StringField, BooleanField, SelectField, TextAreaField
from wtforms.fields.html5 import EmailField, URLField, DecimalField
from wtforms.fields import EmailField, URLField, DecimalField
from metabrainz.model import supporter
from metabrainz.db import tier as db_tier
from flask_uploads import UploadSet, IMAGES
Expand Down
Loading