1 # Copyright (C) 2019 Verizon. All Rights Reserved
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from rest_framework import serializers
17 from catalog.packages import const
20 class OAuthCredentialsSerializer(serializers.Serializer):
21 clientId = serializers.CharField(
22 help_text="Client identifier to be used in the access token "
23 "request of the OAuth 2.0 client credentials grant type.",
28 clientPassword = serializers.CharField(
29 help_text="Client password to be used in the access token "
30 "request of the OAuth 2.0 client credentials grant type.",
35 tokenEndpoint = serializers.CharField(
36 help_text="The token endpoint from which the access token can "
44 class BasicAuthSerializer(serializers.Serializer):
45 userName = serializers.CharField(
46 help_text="Username to be used in HTTP Basic authentication.",
51 password = serializers.CharField(
52 help_text="Password to be used in HTTP Basic authentication.",
59 class SubscriptionAuthenticationSerializer(serializers.Serializer):
60 authType = serializers.ListField(
61 child=serializers.ChoiceField(required=True, choices=const.AUTH_TYPES),
62 help_text="Defines the types of Authentication / Authorization "
63 "which the API consumer is willing to accept when "
64 "receiving a notification.",
67 paramsBasic = BasicAuthSerializer(
68 help_text="Parameters for authentication/authorization using BASIC.",
72 paramsOauth2ClientCredentials = OAuthCredentialsSerializer(
73 help_text="Parameters for authentication/authorization using "
74 "OAUTH2_CLIENT_CREDENTIALS.",