przekazanie do sekretów do env - test only

This commit is contained in:
Jakub K 2024-01-22 21:44:59 +01:00
parent 0f122f0201
commit 22728403ee
3 changed files with 22 additions and 3 deletions

View File

@ -4,7 +4,8 @@ WORKDIR /usr/scr/app
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV REACT_CLIENT_ID="aNTgOypzDqw4BC3QDIAl7OlTUSBEoHKKWCM0LuRG"
ENV REACT_CLIENT_SECRET="W21lvouisPlDKJCKH2QvL0tI5PuQjVlmKzOSqnDTGQmKruQuNl38WyrBzCc2b4A7FhuOAxaLTe5TM8myqvibkglRRTAtxeh5UyM8HsI6ww28ARTK6hdH9xSk5l1JnKVB"
RUN pip install --upgrade pip
COPY ./requirements.txt .
RUN pip install -r requirements.txt

View File

@ -17,6 +17,10 @@ import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
REACT_CLIENT_ID = os.environ.get("REACT_CLIENT_ID")
REACT_CLIENT_SECRET = os.environ.get("LNKAYGodboIVuu4N9qECka8DaVUGd5YaKkE17fvrlXjw7fCdCTYo8uOtm39wm3Xk6PSVIhMPjhFmDGUswi3pQT4rgkvhnm8VRZyLhQYlJSqwnGMPw5AaHSxkRLh7g25A")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

View File

@ -2,12 +2,14 @@ from rest_framework import viewsets, permissions, authentication
from rest_framework.response import Response
from jobposting.models import JobListing, SkillLevels, CompanyLogo, Skill
from core.models import MyUser, AnonymousUserData
from rest_framework import status
from rest_framework import status,
from jobposting.permissions import ClientCredentialPermission
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope, OAuth2Authentication
from .auth import OAuth2ClientCredentialAuthentication
from rest_framework.views import APIView
import requests
from django.conf import settings
permissions.IsAuthenticated
from jobposting.serializers import (
JobListingSerializer,
SkillLevelsSerializer,
@ -86,3 +88,15 @@ class SkillViewset(viewsets.ModelViewSet):
queryset = Skill.objects.all()
serializer_class = SkillSerializer
required_scope = ['main']
class GetAuthTokenView(APIView):
def post(self, request):
client_id = settings.OAUTH_CLIENT_ID
client_secret = settings.OAUTH_CLIENT_SECRET
data = {
'grant_type': 'client_credentials',
'client_id': client_id,
'client_secret': client_secret,
}
response = requests.post('http://izaac.izaac.pl/token', data=data)
return Response(response.json())