Skip to content

Commit

Permalink
Merge pull request #102 from unb-mds/87/task/atualizar-endpoints-para…
Browse files Browse the repository at this point in the history
…-o-login-microsoft

Microsoft(MSAL): Redireciona usuário para a página inicial após login e ajusta fluxo de autenticação
  • Loading branch information
Potatoyz908 authored Dec 11, 2024
2 parents 77f7864 + 443de4c commit 96c4215
Show file tree
Hide file tree
Showing 19 changed files with 778 additions and 60 deletions.
Binary file modified API/AcheiUnB/__pycache__/urls.cpython-312.pyc
Binary file not shown.
18 changes: 8 additions & 10 deletions API/AcheiUnB/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
from channels.auth import AuthMiddlewareStack
from chat.routing import websocket_urlpatterns

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'AcheiUnB.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AcheiUnB.settings")

application = ProtocolTypeRouter({
"http": get_asgi_application(),
"websocket": AuthMiddlewareStack(
URLRouter(
websocket_urlpatterns
)
),
})
application = ProtocolTypeRouter(
{
"http": get_asgi_application(),
"websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns)),
}
)

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'AcheiUnB.settings')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "AcheiUnB.settings")

application = get_asgi_application()
27 changes: 18 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 = []
ALLOWED_HOSTS = ["0.0.0.0", "localhost"]


# Application definition
Expand All @@ -46,7 +46,7 @@
"django_extensions",
"channels",
"chat",
"corsheaders"
"corsheaders",
]

MIDDLEWARE = [
Expand All @@ -58,12 +58,10 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.contrib.messages.middleware.MessageMiddleware"
"django.contrib.messages.middleware.MessageMiddleware",
]

AUTHENTICATION_BACKENDS = [
"django.contrib.auth.backends.ModelBackend"
]
AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend"]


ROOT_URLCONF = "AcheiUnB.urls"
Expand Down Expand Up @@ -116,16 +114,27 @@
"APP": {
"client_id": os.getenv("MICROSOFT_CLIENT_ID"),
"secret": os.getenv("MICROSOFT_CLIENT_SECRET"),
"authority": os.getenv("MICROSOFT_AUTHORITY"),
"key": "",
},
}
}
MICROSOFT_REDIRECT_URI = "http://localhost:8000/microsoft/callback/"
MICROSOFT_REDIRECT_URI = "http://localhost:8000/accounts/microsoft/login/callback/"
# Permitir apenas usuários do tenant da UnB
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS["microsoft"]["AUTH_PARAMS"] = {
"domain": "alunos.unb.br",
}
SOCIALACCOUNT_PROVIDERS["microsoft"]["SCOPE"] = [
"email",
"openid",
"profile",
"User.Read",
]

ACCOUNT_ADAPTER = "allauth.account.adapter.DefaultAccountAdapter"
SOCIALACCOUNT_ADAPTER = "allauth.socialaccount.adapter.DefaultSocialAccountAdapter"
SOCIALACCOUNT_ADAPTER = "users.adapters.CustomSocialAccountAdapter"


# Database
Expand Down Expand Up @@ -179,7 +188,7 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/

STATIC_URL = '/static/'
STATIC_URL = "/static/"

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "AcheiUnB/static/dist"), # Diretório dos arquivos do Vue.js
Expand All @@ -197,5 +206,5 @@
LANGUAGE_CODE = "pt-br"

CORS_ALLOWED_ORIGINS = [
'http://localhost:5173',
"http://localhost:5173",
]
Loading

0 comments on commit 96c4215

Please sign in to comment.