Currently in private beta

The fastest way to build top-notch apps with less code

Introducing the powerful combination of Flutter, Django, and Kubernetes - the DjangoFlow framework. Built-in open source following the Don't Repeat Yourself and zero tech debt principle
Perfect for developers who demand

High efficiency

Short deadlines

Cost savings

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Experience the power of the open-source, highly scalable, and fast full-stack framework.

 
 DF_AUTH = {
    "USER_IDENTITY_FIELDS": {
        "username": "rest_framework.serializers.CharField",
        "email": "rest_framework.serializers.CharField",
    },
    "OTP_IDENTITY_UPDATE_FIELD": False,
}

AUTHENTICATION_BACKENDS = [
    "django.contrib.auth.backends.ModelBackend",
    "social_core.backends.google.GoogleOAuth2",
    "social_core.backends.facebook.FacebookOAuth2",
    "social_core.backends.apple.AppleIdAuth",
    "social_core.backends.twitter.TwitterOAuth",
    "social_core.backends.discord.DiscordOAuth2",
    "df_auth.backends.TestEmailBackend",
    "df_auth.backends.TwilioSMSOTPBackend",
    "df_auth.backends.EmailOTPBackend",
]

REST_FRAMEWORK = {**REST_FRAMEWORK}
REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] += (
    "rest_framework.authentication.SessionAuthentication",
)

SPECTACULAR_SETTINGS = {**SPECTACULAR_SETTINGS}

SOCIAL_AUTH_FACEBOOK_KEY = "xxxxxxx"
SOCIAL_AUTH_FACEBOOK_SECRET = "xxxxxxx"


Heading

Python/Django

    
      // generated api client
      class AuthApi {
        final Dio _dio;

        const AuthApi(this._dio);

        /// authOtpCreate
        ///
        /// Parameters:
        /// * [oTPObtainRequest]
        /// * [cancelToken] - A [CancelToken] that can be used to cancel the operation
        /// * [headers] - Can be used to add additional headers to the request
        /// * [extras] - Can be used to add flags to the request
        /// * [validateStatus] - A [ValidateStatus] callback that can be used to determine request success based on the HTTP status of the response
        /// * [onSendProgress] - A [ProgressCallback] that can be used to get the send progress
        /// * [onReceiveProgress] - A [ProgressCallback] that can be used to get the receive progress
        ///
        /// Returns a [Future] containing a [Response] with a [OTPObtain] as data
        /// Throws [DioException] if API call or serialization fails
        Future<Response<OTPObtain>> authOtpCreate({
          OTPObtainRequest? oTPObtainRequest,
          CancelToken? cancelToken,
          Map<String, dynamic>? headers,
          Map<String, dynamic>? extra,
          ValidateStatus? validateStatus,
          ProgressCallback? onSendProgress,
          ProgressCallback? onReceiveProgress,
        }) async {
          final _path = r'/api/v1/auth/otp/';
          final _options = Options(
            method: r'POST',
            headers: <String, dynamic>{
              ...?headers,
            },
            extra: <String, dynamic>{
              'secure': <Map<String, String>>[
                {
                  'type': 'http',
                  'scheme': 'bearer',
                  'name': 'jwtAuth',
                },
              ],
              ...?extra,
            },
            contentType: 'application/json',
            validateStatus: validateStatus,
          );

          dynamic _bodyData;

          try {
            _bodyData = jsonEncode(oTPObtainRequest);
          } catch (error, stackTrace) {
            throw DioException(
              requestOptions: _options.compose(
                _dio.options,
                _path,
              ),
              type: DioExceptionType.unknown,
              error: error,
              stackTrace: stackTrace,
            );
          }

          final _response = await _dio.request<Object>(
            _path,
            data: _bodyData,
            options: _options,
            cancelToken: cancelToken,
            onSendProgress: onSendProgress,
            onReceiveProgress: onReceiveProgress,
          );

          OTPObtain? _responseData;

          try {
            final rawData = _response.data;
            _responseData = rawData == null ? null : deserialize<OTPObtain, OTPObtain>(rawData, 'OTPObtain', growable: true);
          } catch (error, stackTrace) {
            throw DioException(
              requestOptions: _response.requestOptions,
              response: _response,
              type: DioExceptionType.unknown,
              error: error,
              stackTrace: stackTrace,
            );
          }

          return Response<OTPObtain>(
            data: _responseData,
            headers: _response.headers,
            isRedirect: _response.isRedirect,
            requestOptions: _response.requestOptions,
            redirects: _response.redirects,
            statusCode: _response.statusCode,
            statusMessage: _response.statusMessage,
            extra: _response.extra,
          );
        }
      }

      // business logic implemented using generated client which can be integrated with any project using the django modules of djangoflow
      class AuthCubit extends HydratedAuthCubitBase {
        AuthCubit._internal() : super(const AuthState.initial());
        AuthApi? authApi;

        static AuthCubit get instance => _instance;
        static final AuthCubit _instance = AuthCubit._internal();

        @override
        AuthState? fromJson(Map<String, dynamic> json) => AuthState.fromJson(json);

        @override
        Map<String, dynamic>? toJson(AuthState state) => state.toJson();

        /// Authenticate and request token for user from the Social Auth Provider
        /// eg, facebook, google etc.
        @override
        Future<R?> requestTokenFromSocialProvider<R>(SocialLoginType type) async {
          final provider = _firstWhereSocialLogin(type);
          if (provider == null) {
            throw _loginProviderNotFoundException(type);
          }

          final response = (await provider.login()) as R?;
          return response;
        }

        @override
        Future<void> logoutFromSocialProvider(SocialLoginType type) async {
          final socialLogin = _firstWhereSocialLogin(type);
          if (socialLogin == null) {
            throw _loginProviderNotFoundException(type);
          }

          await socialLogin.logout();
        }

        SocialLogin<dynamic>? _firstWhereSocialLogin(SocialLoginType type) =>
            socialLogins.firstWhereOrNull(
              (element) => element.type == type,
            );

        LoginProviderNotFoundException _loginProviderNotFoundException(
          SocialLoginType type, {
          String? message,
        }) =>
            LoginProviderNotFoundException(
              message ?? 'Social Provider ${type.provider.name} was not found',
            );

        /// Logout user, also removes token from storage and logs out user from social logins
        @override
        Future<void> logout() async {
          for (final provider in socialLogins) {
            await provider.logout();
          }
          emit(
            const AuthState.unauthenticated(),
          );
        }
      }
    
  

Heading

Dart/Flutter

Sign up for our closed beta

Be among the first to experience the power of Flutter, Django, and Kubernetes combined.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.