Updates for single-sign-on support

This commit is contained in:
Drew DeVault 2019-11-30 10:17:42 -05:00
parent c443228630
commit 856ad5b04e
9 changed files with 20 additions and 14 deletions

View File

@ -19,8 +19,15 @@ owner-email=sir@cmpwn.com
# The source code for your fork of sr.ht # The source code for your fork of sr.ht
source-url=https://git.sr.ht/~sircmpwn/srht source-url=https://git.sr.ht/~sircmpwn/srht
# #
# A secret key to encrypt session cookies with # A secret key to encrypt session cookies with. Use `srht-keygen service` to
secret-key=CHANGEME # generate this. This should be unique to each site, but shared among nodes of
# that site. For example, git.sr.ht and hg.sr.ht have different keys, but
# git1.sr.ht has the same key as git2.sr.ht.
service-key=
#
# A secret key to encrypt internal messages with. Use `srht-keygen network` to
# generate this. This should be consistent between all *.sr.ht sites and nodes.
network-key=
[mail] [mail]
# #

View File

@ -4,6 +4,7 @@ owner-name=Drew DeVault
owner-email=sir@cmpwn.com owner-email=sir@cmpwn.com
source-url=https://git.sr.ht/~sircmpwn/srht source-url=https://git.sr.ht/~sircmpwn/srht
secret-key= secret-key=
network-key=
[mail] [mail]
smtp-host= smtp-host=

View File

@ -53,7 +53,6 @@ setup(
url = 'https://todo.sr.ht/~sircmpwn/todo.sr.ht', url = 'https://todo.sr.ht/~sircmpwn/todo.sr.ht',
install_requires = [ install_requires = [
'alembic', 'alembic',
'flask-login',
'pystache', 'pystache',
'redis', 'redis',
'srht', 'srht',

View File

@ -1,4 +1,4 @@
from flask_login import current_user from srht.oauth import current_user
from todosrht.types import User, Tracker, Ticket from todosrht.types import User, Tracker, Ticket
from todosrht.types import TicketAccess, UserAccess from todosrht.types import TicketAccess, UserAccess

View File

@ -1,10 +1,10 @@
from flask import Blueprint, render_template, request, abort from flask import Blueprint, render_template, request, abort
from flask_login import current_user
from todosrht.access import get_tracker, get_access from todosrht.access import get_tracker, get_access
from todosrht.tickets import get_participant_for_user from todosrht.tickets import get_participant_for_user
from todosrht.types import Tracker, Ticket, Event, EventNotification, EventType from todosrht.types import Tracker, Ticket, Event, EventNotification, EventType
from todosrht.types import User, Participant from todosrht.types import User, Participant
from srht.config import cfg from srht.config import cfg
from srht.oauth import current_user
from srht.flask import paginate_query, session from srht.flask import paginate_query, session
from sqlalchemy import and_, or_ from sqlalchemy import and_, or_

View File

@ -3,12 +3,12 @@ import json
import os import os
from collections import OrderedDict from collections import OrderedDict
from flask import Blueprint, render_template, request, url_for, abort, redirect from flask import Blueprint, render_template, request, url_for, abort, redirect
from flask import send_file from flask import current_app, send_file
from flask_login import current_user
from srht.config import get_origin from srht.config import get_origin
from srht.crypto import sign_payload from srht.crypto import sign_payload
from srht.database import db from srht.database import db
from srht.flask import date_handler, loginrequired, session from srht.oauth import current_user, loginrequired
from srht.flask import date_handler, session
from srht.validation import Validation from srht.validation import Validation
from tempfile import NamedTemporaryFile from tempfile import NamedTemporaryFile
from todosrht.access import get_tracker from todosrht.access import get_tracker
@ -141,7 +141,7 @@ def user_access_create_POST(owner, name):
return render_tracker_access(tracker, **valid.kwargs), 400 return render_tracker_access(tracker, **valid.kwargs), 400
username = username.lstrip("~") username = username.lstrip("~")
user = User.query.filter_by(username=username).one_or_none() user = current_app.oauth_service.lookup_user(username)
valid.expect(user, "User not found.", field="username") valid.expect(user, "User not found.", field="username")
if not valid.ok: if not valid.ok:
return render_tracker_access(tracker, **valid.kwargs), 400 return render_tracker_access(tracker, **valid.kwargs), 400

View File

@ -1,10 +1,9 @@
import re import re
from urllib.parse import quote from urllib.parse import quote
from flask import Blueprint, render_template, request, abort, redirect from flask import Blueprint, render_template, request, abort, redirect
from flask_login import current_user
from srht.config import cfg from srht.config import cfg
from srht.database import db from srht.database import db
from srht.flask import loginrequired from srht.oauth import current_user, loginrequired
from srht.validation import Validation from srht.validation import Validation
from todosrht.access import get_tracker, get_ticket from todosrht.access import get_tracker, get_ticket
from todosrht.filters import invalidate_markup_cache from todosrht.filters import invalidate_markup_cache

View File

@ -1,5 +1,4 @@
from flask import Blueprint, render_template, request, url_for, abort, redirect from flask import Blueprint, render_template, request, url_for, abort, redirect
from flask_login import current_user
from todosrht.color import color_from_hex, color_to_hex, get_text_color from todosrht.color import color_from_hex, color_to_hex, get_text_color
from todosrht.color import valid_hex_color_code from todosrht.color import valid_hex_color_code
from todosrht.access import get_tracker from todosrht.access import get_tracker
@ -14,7 +13,8 @@ from todosrht.urls import tracker_url, ticket_url
from todosrht.webhooks import TrackerWebhook, UserWebhook from todosrht.webhooks import TrackerWebhook, UserWebhook
from srht.config import cfg from srht.config import cfg
from srht.database import db from srht.database import db
from srht.flask import paginate_query, loginrequired, session from srht.flask import paginate_query, session
from srht.oauth import current_user, loginrequired
from srht.validation import Validation from srht.validation import Validation
from sqlalchemy.orm import subqueryload from sqlalchemy.orm import subqueryload

View File

@ -2,9 +2,9 @@ import html.parser
import os import os
import pystache import pystache
import textwrap import textwrap
from flask_login import current_user
from srht.config import cfg, cfgi from srht.config import cfg, cfgi
from srht.email import send_email, lookup_key from srht.email import send_email, lookup_key
from srht.oauth import current_user
from todosrht.types import ParticipantType from todosrht.types import ParticipantType
origin = cfg("todo.sr.ht", "origin") origin = cfg("todo.sr.ht", "origin")