CVAT authentication (#5147)
parent
8a44a36c74
commit
bb487165dd
@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2022 CVAT.ai Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import React from 'react';
|
||||
import { Col, Row } from 'antd/lib/grid';
|
||||
import Layout from 'antd/lib/layout';
|
||||
import Button from 'antd/lib/button';
|
||||
import './styles.scss';
|
||||
|
||||
const { Content } = Layout;
|
||||
|
||||
/**
|
||||
* Component for displaying message that email should be verified
|
||||
*/
|
||||
|
||||
export default function EmailVerificationSentPage(): JSX.Element {
|
||||
return (
|
||||
<Layout>
|
||||
<Content>
|
||||
<Row justify='center' align='middle' id='email-verification-sent-page-container'>
|
||||
<Col>
|
||||
<h1>Please, confirm your email</h1>
|
||||
<Button type='link' href='/auth/login'>
|
||||
Go to login page
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Content>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2022 CVAT.ai Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import React from 'react';
|
||||
import { Col, Row } from 'antd/lib/grid';
|
||||
import Layout from 'antd/lib/layout';
|
||||
import Button from 'antd/lib/button';
|
||||
import './styles.scss';
|
||||
|
||||
const { Content } = Layout;
|
||||
|
||||
/**
|
||||
* Component for displaying message that email confirmation URL is incorrect
|
||||
*/
|
||||
|
||||
export default function IncorrectEmailConfirmationPage(): JSX.Element {
|
||||
return (
|
||||
<Layout>
|
||||
<Content>
|
||||
<Row justify='center' align='middle' id='incorrect-email-confirmation-page-container'>
|
||||
<Col>
|
||||
<h1>
|
||||
This e-mail confirmation link expired or is invalid.
|
||||
</h1>
|
||||
<p>
|
||||
Please issue a new e-mail confirmation request.
|
||||
</p>
|
||||
<Button type='link' href='/auth/login'>
|
||||
Go to login page
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
</Content>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
# Copyright (C) 2022 CVAT.ai Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.http import HttpResponseRedirect, HttpResponseBadRequest
|
||||
from django.conf import settings
|
||||
|
||||
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
|
||||
from allauth.account.adapter import DefaultAccountAdapter
|
||||
from allauth.socialaccount.providers.github.views import GitHubOAuth2Adapter
|
||||
from allauth.socialaccount.providers.google.views import GoogleOAuth2Adapter
|
||||
from allauth.exceptions import ImmediateHttpResponse
|
||||
from allauth.account.utils import filter_users_by_email
|
||||
|
||||
UserModel = get_user_model()
|
||||
|
||||
class DefaultAccountAdapterEx(DefaultAccountAdapter):
|
||||
def respond_email_verification_sent(self, request, user):
|
||||
return HttpResponseRedirect(settings.ACCOUNT_EMAIL_VERIFICATION_SENT_REDIRECT_URL)
|
||||
|
||||
class SocialAccountAdapterEx(DefaultSocialAccountAdapter):
|
||||
def pre_social_login(self, request, sociallogin):
|
||||
"""
|
||||
Invoked just after a user successfully authenticates via a
|
||||
social provider, but before the login is actually processed
|
||||
(and before the pre_social_login signal is emitted).
|
||||
"""
|
||||
if sociallogin.is_existing:
|
||||
return
|
||||
|
||||
if not sociallogin.email_addresses:
|
||||
raise ImmediateHttpResponse(response=HttpResponseBadRequest('No email is associated with this social account'))
|
||||
|
||||
users = filter_users_by_email(sociallogin.user.email)
|
||||
if len(users) > 1:
|
||||
raise ImmediateHttpResponse(HttpResponseBadRequest(f'Cannot connect account with ${sociallogin.user.email} email.'))
|
||||
elif users:
|
||||
sociallogin.connect(request, users[0])
|
||||
return
|
||||
|
||||
class GitHubAdapter(GitHubOAuth2Adapter):
|
||||
def get_callback_url(self, request, app):
|
||||
return settings.GITHUB_CALLBACK_URL
|
||||
|
||||
class GoogleAdapter(GoogleOAuth2Adapter):
|
||||
def get_callback_url(self, request, app):
|
||||
return settings.GOOGLE_CALLBACK_URL
|
||||
@ -1,5 +1,5 @@
|
||||
Scope,Resource,Context,Ownership,Limit,Method,URL,Privilege,Membership
|
||||
view,N/A,N/A,N/A,,GET,"/server/about, /server/annotation/formats, /server/plugins",None,N/A
|
||||
view,N/A,N/A,N/A,,GET,"/server/about, /server/annotation/formats, /server/plugins, /server/advanced-auth",None,N/A
|
||||
send:exception,N/A,N/A,N/A,,POST,/server/exception,None,N/A
|
||||
send:logs,N/A,N/A,N/A,,POST,/server/logs,None,N/A
|
||||
list:content,N/A,N/A,N/A,,GET,/server/share,Worker,N/A
|
||||
|
@ -0,0 +1,288 @@
|
||||
<!DOCTYPE html>
|
||||
{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}
|
||||
{% load static %}
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||
<title>Email Confirmation</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type="text/css">
|
||||
/**
|
||||
* Google webfonts. Recommended to include the .woff version for cross-client compatibility.
|
||||
*/
|
||||
@media screen {
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Source Sans Pro Regular'), local('SourceSansPro-Regular'), url(https://fonts.gstatic.com/s/sourcesanspro/v10/ODelI1aHBYDBqgeIAH2zlBM0YzuT7MdOe03otPbuUS0.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Source Sans Pro';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Source Sans Pro Bold'), local('SourceSansPro-Bold'), url(https://fonts.gstatic.com/s/sourcesanspro/v10/toadOcfmlt9b38dHJxOBGFkQc6VGVFSmCnC_l7QZG60.woff) format('woff');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Avoid browser level font resizing.
|
||||
* 1. Windows Mobile
|
||||
* 2. iOS / OSX
|
||||
*/
|
||||
body,
|
||||
table,
|
||||
td,
|
||||
a {
|
||||
-ms-text-size-adjust: 100%; /* 1 */
|
||||
-webkit-text-size-adjust: 100%; /* 2 */
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra space added to tables and cells in Outlook.
|
||||
*/
|
||||
table,
|
||||
td {
|
||||
mso-table-rspace: 0pt;
|
||||
mso-table-lspace: 0pt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Better fluid images in Internet Explorer.
|
||||
*/
|
||||
img {
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove blue links for iOS devices.
|
||||
*/
|
||||
a[x-apple-data-detectors] {
|
||||
font-family: inherit !important;
|
||||
font-size: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix centering issues in Android 4.4.
|
||||
*/
|
||||
div[style*="margin: 16px 0;"] {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapse table borders to avoid space between cells.
|
||||
*/
|
||||
table {
|
||||
border-collapse: collapse !important;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #1a82e2;
|
||||
}
|
||||
|
||||
img {
|
||||
height: auto;
|
||||
line-height: 100%;
|
||||
text-decoration: none;
|
||||
border: 0;
|
||||
outline: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body style="background-color: #e9ecef;">
|
||||
|
||||
<!-- start preheader -->
|
||||
<div class="preheader" style="display: none; max-width: 0; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: #fff; opacity: 0;">
|
||||
A preheader is the short summary text that follows the subject line when an email is viewed in the inbox.
|
||||
</div>
|
||||
<!-- end preheader -->
|
||||
|
||||
<!-- start body -->
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
|
||||
<!-- start logo -->
|
||||
<tr>
|
||||
<td align="center" bgcolor="#e9ecef">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td align="center" valign="top" width="600">
|
||||
<![endif]-->
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
|
||||
<tr>
|
||||
<td align="center" valign="bottom">
|
||||
<a href="https://www.cvat.ai/" target="_blank" style="display: inline-block;">
|
||||
<img
|
||||
src="https://github.com/opencv/cvat/blob/develop/site/content/en/images/cvat_poster_with_name.png?raw=true"
|
||||
alt="Logo"
|
||||
border="0"
|
||||
width="100%"
|
||||
style="display: block; width: 100%;"
|
||||
>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end logo -->
|
||||
|
||||
<!-- start hero -->
|
||||
<tr>
|
||||
<td align="center" bgcolor="#e9ecef">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td align="center" valign="top" width="600">
|
||||
<![endif]-->
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
|
||||
<tr>
|
||||
<td align="left" bgcolor="#ffffff" style="padding: 36px 24px 0; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; border-top: 3px solid #d4dadf;">
|
||||
<h1 style="margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -1px; line-height: 48px;">
|
||||
Confirm Your Email Address
|
||||
</h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end hero -->
|
||||
|
||||
<!-- start copy block -->
|
||||
<tr>
|
||||
<td align="center" bgcolor="#e9ecef">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td align="center" valign="top" width="600">
|
||||
<![endif]-->
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
|
||||
|
||||
<!-- start copy -->
|
||||
<tr>
|
||||
<td align="left" bgcolor="#ffffff" style="padding: 24px; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px;">
|
||||
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}
|
||||
<p>
|
||||
Thank you for signing up for CVAT!
|
||||
</p>
|
||||
<p style="margin: 0;">
|
||||
To complete registration and start annotating, simply tap the button below and confirm your email address.
|
||||
If you didn't create an account with <strong>{{ site_name }}</strong>,
|
||||
you can safely delete this email.
|
||||
</p>
|
||||
{% endblocktrans %}
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end copy -->
|
||||
|
||||
<!-- start button -->
|
||||
<tr>
|
||||
<td align="left" bgcolor="#ffffff">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td align="center" bgcolor="#ffffff" style="padding: 12px;">
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center" bgcolor="#FCA836" style="border-radius: 6px;">
|
||||
<a
|
||||
href="{{ activate_url }}"
|
||||
target="_blank"
|
||||
style="display: inline-block; padding: 16px 36px;"
|
||||
"font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif;"
|
||||
"font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Confirm
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end button -->
|
||||
|
||||
<!-- start copy -->
|
||||
<tr>
|
||||
<td align="left" bgcolor="#ffffff" style="padding: 24px; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 24px; border-bottom: 3px solid #d4dadf">
|
||||
<hr>
|
||||
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}
|
||||
<p style="margin: 0;">
|
||||
<strong>{{ site_domain }}</strong>
|
||||
</p>
|
||||
{% endblocktrans %} {% endautoescape %}
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end copy -->
|
||||
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end copy block -->
|
||||
|
||||
<!-- start footer -->
|
||||
<tr>
|
||||
<td align="center" bgcolor="#e9ecef" style="padding: 24px;">
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
<table align="center" border="0" cellpadding="0" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td align="center" valign="top" width="600">
|
||||
<![endif]-->
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
|
||||
|
||||
<!-- start permission -->
|
||||
<tr>
|
||||
<td align="center" bgcolor="#e9ecef" style="padding: 12px 24px; font-family: 'Source Sans Pro', Helvetica, Arial, sans-serif; font-size: 14px; line-height: 20px; color: #666;">
|
||||
<p style="margin: 0;">If you didn't request this, please ignore this email.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end permission -->
|
||||
|
||||
</table>
|
||||
<!--[if (gte mso 9)|(IE)]>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<![endif]-->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end footer -->
|
||||
|
||||
</table>
|
||||
<!-- end body -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -1,14 +1 @@
|
||||
{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}
|
||||
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}
|
||||
Hello from {{ site_name }}!
|
||||
|
||||
<p>
|
||||
You're receiving this e-mail because user <strong>{{ user_display }}</strong> has given yours as an e-mail address
|
||||
to connect their account.
|
||||
</p>
|
||||
|
||||
<p>To confirm this is correct, go to <a href="{{ activate_url }}">{{ activate_url }}</a></p>
|
||||
{% endblocktrans %}
|
||||
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}
|
||||
<strong>{{ site_domain }}</strong>
|
||||
{% endblocktrans %} {% endautoescape %}
|
||||
{% include "account/email/email_confirmation_message.html" %}
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
{% load i18n %}
|
||||
{% autoescape off %}
|
||||
{% blocktrans %}Confirm your email adress{% endblocktrans %}
|
||||
{% endautoescape %}
|
||||
@ -0,0 +1,13 @@
|
||||
{{- if .Values.cvat.backend.server.secret.create }}
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: "{{ .Release.Name }}-{{ .Values.cvat.backend.server.secret.name }}"
|
||||
namespace: {{ .Release.Namespace }}
|
||||
type: generic
|
||||
stringData:
|
||||
googleClientId: {{ .Values.cvat.backend.server.secret.socialAccountAuthentication.googleClientId | b64enc }}
|
||||
googleClientSecret: {{ .Values.cvat.backend.server.secret.socialAccountAuthentication.googleClientSecret | b64enc }}
|
||||
githubClientId: {{ .Values.cvat.backend.server.secret.socialAccountAuthentication.githubClientId | b64enc }}
|
||||
githubClientSecret: {{ .Values.cvat.backend.server.secret.socialAccountAuthentication.githubClientSecret | b64enc }}
|
||||
{{- end }}
|
||||
Loading…
Reference in New Issue