from sqlalchemy.orm import joinedload from sqlalchemy.orm.exc import NoResultFound from .identity import FreeUser, users class OAuthError(Exception): pass def base64_pad(s): padding = 4 - (len(s) % 4) return s + ("=" * padding) jwt_decode = compose(json.loads, base64.urlsafe_b64decode, base64_pad) def setup_oauth_gitlab(oauth): oauth.register( "gitlab", access_token_url="https://gitlab.com/oauth/token", client_kwargs={"scope": "openid read_user"}, authorize_url="https://gitlab.com/oauth/authorize", ) oauthBP = Blueprint("OAuth.GitLab", __name__, url_prefix="/oauth/gitlab") @oauthBP.route("/login") def login(): redirect_uri = url_for(".authorize", _external=True)
def __init__(self, *args, **kwargs): hooks = compose(kwargs.pop("object_hook", None), self.hook) super().__init__(*args, **kwargs, object_hook=hooks)