Skip to content

Commit

Permalink
Merge pull request #100 from unb-mds/90-93/feat/adicionar-tela-achados
Browse files Browse the repository at this point in the history
Task(Implementação-Inicial): Adiciona o main menu, responsive layout e Microsoft authentication
  • Loading branch information
Potatoyz908 authored Dec 11, 2024
2 parents dca4b4d + c4c56ec commit 882793a
Show file tree
Hide file tree
Showing 84 changed files with 558 additions and 59 deletions.
Binary file modified API/AcheiUnB/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified API/AcheiUnB/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified API/AcheiUnB/__pycache__/wsgi.cpython-312.pyc
Binary file not shown.
15 changes: 6 additions & 9 deletions API/AcheiUnB/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['0.0.0.0']
ALLOWED_HOSTS = []


# Application definition
Expand All @@ -40,11 +40,9 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.microsoft",
"users",
"rest_framework",
"AcheiUnB",
"django_extensions",
"channels",
"chat",
Expand All @@ -60,13 +58,11 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django.contrib.messages.middleware.MessageMiddleware"
]

AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend",
"allauth.account.auth_backends.AuthenticationBackend",
"django.contrib.auth.backends.ModelBackend"
]


Expand Down Expand Up @@ -124,6 +120,7 @@
},
}
}
MICROSOFT_REDIRECT_URI = "http://localhost:8000/microsoft/callback/"
# Permitir apenas usuários do tenant da UnB
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS["microsoft"]["AUTH_PARAMS"] = {
Expand Down
23 changes: 6 additions & 17 deletions API/AcheiUnB/urls.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
"""
URL configuration for AcheiUnB project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.contrib.auth import views as auth_views
Expand All @@ -22,14 +6,19 @@
TokenRefreshView,
)
from django.shortcuts import render
from users import views
from users.views import microsoft_callback


# View para servir o arquivo Vue.js
def vue_app(request):
return render(request, 'index.html') # Caminho para o index.html dentro da pasta templates

urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')), # Rotas do Allauth para login pelo Microsoft
path("microsoft/login/", views.microsoft_login, name="microsoft_login"),
path("microsoft/callback/", views.microsoft_callback, name="microsoft_callback"),
path("accounts/microsoft/login/callback/", microsoft_callback, name="microsoft_callback"),
path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
path('', vue_app, name='vue_home'), # Essa URL renderiza o arquivo index.html
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), # Obter token de acesso e refresh
Expand Down
4 changes: 2 additions & 2 deletions API/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ asgiref==3.8.1
certifi==2024.8.30
charset-normalizer==3.4.0
Django==5.1.4
django-allauth==65.1.0
idna==3.10
psycopg2-binary==2.9.10
requests==2.32.3
Expand All @@ -14,4 +13,5 @@ djangorestframework
django-extensions
djangorestframework-simplejwt
channels
django-cors-headers==4.6.0
django-cors-headers==4.6.0
msal
Binary file modified API/users/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file modified API/users/__pycache__/admin.cpython-312.pyc
Binary file not shown.
Binary file modified API/users/__pycache__/apps.cpython-312.pyc
Binary file not shown.
Binary file modified API/users/__pycache__/models.cpython-312.pyc
Binary file not shown.
Binary file modified API/users/__pycache__/views.cpython-312.pyc
Binary file not shown.
Binary file modified API/users/migrations/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
50 changes: 47 additions & 3 deletions API/users/views.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from django.shortcuts import render
from django.contrib.auth import login
from django.shortcuts import redirect
from django.contrib import messages
from django.contrib.auth.models import User
from django.utils.crypto import get_random_string
from rest_framework.generics import ListCreateAPIView
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from .models import Item
from .serializers import ItemSerializer
from msal import ConfidentialClientApplication
from django.shortcuts import redirect
from django.http import JsonResponse
import os

# Configurações do MSAL
CLIENT_ID = os.getenv("MICROSOFT_CLIENT_ID")
CLIENT_SECRET = os.getenv("MICROSOFT_CLIENT_SECRET")
AUTHORITY = os.getenv("MICROSOFT_AUTHORITY")
REDIRECT_URI = os.getenv("MICROSOFT_REDIRECT_URI")


class ItemListCreateView(ListCreateAPIView):
Expand Down Expand Up @@ -36,4 +44,40 @@ def perform_create(self, serializer):
def ItemListCreateView(ListCreateAPIView):
queryset = Item.objects.all()
serializer_class= ItemSerializer
permission_classes = [IsAuthenticatedOrReadOnly]
permission_classes = [IsAuthenticatedOrReadOnly]

def microsoft_login(request):
"""Inicia o fluxo de login com Microsoft."""
app = ConfidentialClientApplication(
CLIENT_ID, authority=AUTHORITY, client_credential=CLIENT_SECRET
)
# URL para redirecionar o usuário para o login da Microsoft
auth_url = app.get_authorization_request_url(
scopes=["User.Read"], # Scopes solicitados
redirect_uri=REDIRECT_URI,
)
return redirect(auth_url)

def microsoft_callback(request):
"""Processa o callback da Microsoft após o login."""
# Obtém o código de autorização da URL
code = request.GET.get("code")
if not code:
return JsonResponse({"error": "Código de autorização não fornecido."}, status=400)

# Troca o código pelo token
app = ConfidentialClientApplication(
CLIENT_ID, authority=AUTHORITY, client_credential=CLIENT_SECRET
)
result = app.acquire_token_by_authorization_code(
code,
scopes=["User.Read"], # Scopes solicitados
redirect_uri=REDIRECT_URI,
)

if "access_token" in result:
# Você pode usar o token para autenticar o usuário
user_info = result.get("id_token_claims")
return JsonResponse({"message": "Login bem-sucedido!", "user": user_info})
else:
return JsonResponse({"error": "Erro ao obter o token.", "details": result}, status=400)
Binary file not shown.
Binary file not shown.
93 changes: 93 additions & 0 deletions web/src/assets/fonts/Inter/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
118 changes: 118 additions & 0 deletions web/src/assets/fonts/Inter/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
Inter Variable Font
===================

This download contains Inter as both variable fonts and static fonts.

Inter is a variable font with these axes:
opsz
wght

This means all the styles are contained in these files:
Inter-VariableFont_opsz,wght.ttf
Inter-Italic-VariableFont_opsz,wght.ttf

If your app fully supports variable fonts, you can now pick intermediate styles
that aren’t available as static fonts. Not all apps support variable fonts, and
in those cases you can use the static font files for Inter:
static/Inter_18pt-Thin.ttf
static/Inter_18pt-ExtraLight.ttf
static/Inter_18pt-Light.ttf
static/Inter_18pt-Regular.ttf
static/Inter_18pt-Medium.ttf
static/Inter_18pt-SemiBold.ttf
static/Inter_18pt-Bold.ttf
static/Inter_18pt-ExtraBold.ttf
static/Inter_18pt-Black.ttf
static/Inter_24pt-Thin.ttf
static/Inter_24pt-ExtraLight.ttf
static/Inter_24pt-Light.ttf
static/Inter_24pt-Regular.ttf
static/Inter_24pt-Medium.ttf
static/Inter_24pt-SemiBold.ttf
static/Inter_24pt-Bold.ttf
static/Inter_24pt-ExtraBold.ttf
static/Inter_24pt-Black.ttf
static/Inter_28pt-Thin.ttf
static/Inter_28pt-ExtraLight.ttf
static/Inter_28pt-Light.ttf
static/Inter_28pt-Regular.ttf
static/Inter_28pt-Medium.ttf
static/Inter_28pt-SemiBold.ttf
static/Inter_28pt-Bold.ttf
static/Inter_28pt-ExtraBold.ttf
static/Inter_28pt-Black.ttf
static/Inter_18pt-ThinItalic.ttf
static/Inter_18pt-ExtraLightItalic.ttf
static/Inter_18pt-LightItalic.ttf
static/Inter_18pt-Italic.ttf
static/Inter_18pt-MediumItalic.ttf
static/Inter_18pt-SemiBoldItalic.ttf
static/Inter_18pt-BoldItalic.ttf
static/Inter_18pt-ExtraBoldItalic.ttf
static/Inter_18pt-BlackItalic.ttf
static/Inter_24pt-ThinItalic.ttf
static/Inter_24pt-ExtraLightItalic.ttf
static/Inter_24pt-LightItalic.ttf
static/Inter_24pt-Italic.ttf
static/Inter_24pt-MediumItalic.ttf
static/Inter_24pt-SemiBoldItalic.ttf
static/Inter_24pt-BoldItalic.ttf
static/Inter_24pt-ExtraBoldItalic.ttf
static/Inter_24pt-BlackItalic.ttf
static/Inter_28pt-ThinItalic.ttf
static/Inter_28pt-ExtraLightItalic.ttf
static/Inter_28pt-LightItalic.ttf
static/Inter_28pt-Italic.ttf
static/Inter_28pt-MediumItalic.ttf
static/Inter_28pt-SemiBoldItalic.ttf
static/Inter_28pt-BoldItalic.ttf
static/Inter_28pt-ExtraBoldItalic.ttf
static/Inter_28pt-BlackItalic.ttf

Get started
-----------

1. Install the font files you want to use

2. Use your app's font picker to view the font family and all the
available styles

Learn more about variable fonts
-------------------------------

https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
https://variablefonts.typenetwork.com
https://medium.com/variable-fonts

In desktop apps

https://theblog.adobe.com/can-variable-fonts-illustrator-cc
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts

Online

https://developers.google.com/fonts/docs/getting_started
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts

Installing fonts

MacOS: https://support.apple.com/en-us/HT201749
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows

Android Apps

https://developers.google.com/fonts/docs/android
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts

License
-------
Please read the full license text (OFL.txt) to understand the permissions,
restrictions and requirements for usage, redistribution, and modification.

You can use them in your products & projects – print or digital,
commercial or otherwise.

This isn't legal advice, please consider consulting a lawyer and see the full
license for all details.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 882793a

Please sign in to comment.