1 # Copyright (c) 2019, CMCC Technologies Co., Ltd.
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.
16 from rest_framework import serializers
18 from lcm.ns import const
21 class OAuthCredentialsSerializer(serializers.Serializer):
22 clientId = serializers.CharField(
23 help_text="Client identifier to be used in the access token request of the OAuth 2.0 client "
24 "credentials grant type.", required=False, max_length=255, allow_null=False)
25 clientPassword = serializers.CharField(
26 help_text="Client password to be used in the access token request of the OAuth 2.0 client"
27 " credentials grant type.", required=False, max_length=255, allow_null=False)
28 tokenEndpoint = serializers.CharField(
29 help_text="The token endpoint from which the access token can be obtained.", required=False,
34 class BasicAuthSerializer(serializers.Serializer):
35 userName = serializers.CharField(
36 help_text="Username to be used in HTTP Basic authentication.", max_length=255,
39 password = serializers.CharField(
40 help_text="Password to be used in HTTP Basic authentication.", max_length=255,
45 class SubscriptionAuthenticationSerializer(serializers.Serializer):
46 authType = serializers.ListField(
47 child=serializers.ChoiceField(required=True, choices=const.AUTH_TYPES),
48 help_text="Defines the types of Authentication / Authorization which the API consumer is"
49 " willing to accept when receiving a notification.", required=True)
50 paramsBasic = BasicAuthSerializer(
51 help_text="Parameters for authentication/authorization using BASIC.",
54 paramsOauth2ClientCredentials = OAuthCredentialsSerializer(
55 help_text="Parameters for authentication/authorization using OAUTH2_CLIENT_CREDENTIALS.",