Giter Club home page Giter Club logo

awesauthkt's Introduction

AwesAuthKt

Kotlin License

This app is a demonstration of using AppAuth for Android and Google Sign-In for Android for OAuth2 and authentication.

Architecture

This app implements the Clean Architecture proposed by Robert C. Martin (Uncle Bob)

CleanArchitecture

As of Android, it's inspired by an implementation from Fernando Cejas's repo Android-CleanArchitecture-Kotlin

Android 3 Layers Architecture

Android 3 Layers

Presentation Layer

Presentation Layer

Data Layer

Data Layer

Adaption for This App

Since AppAuth for android and Google SignIn have both heavily relied on Android (Activity, Context, Uri, ...), it is impossible to put their logic in Domain layer. Therefore I replace Repository Contact with AuthDelegate to delegate business logic in Data layer and keep Domain layer a pure Kotlin library

Achievements

  • Clean Architecture + MVVM
  • AppAuth for Android client implementation
  • Google SignIn client implementation
  • Coroutines
  • Kodein for DI
  • JUnit Test for database with RobolectricTest + Mockito + JUnit
  • Android Instrumentation Test for database

TO DO LIST

  • JUnit Test for UI (It might be hard to do because AppAuth and Google SignIn use external Chrome to do authorization and authentication, it's hard to simulate user log in actions)

AppAuth for Android

The app uses Google OAuth2 configuration google_config.json. To run it on your own, you have to create a configuration json as the res/raw/xxx.json

{
  "client_id": "YOUR CLIENT ID REGISTERED IN YOUR OAUTH2 PROVIDER",
  "redirect_uri": "XXX.XXX:/",
  "authorization_scope": "openid email profile",
  "discovery_uri": "YOUR OAUTH2 PROVIDER'S URI TO FETCH DISCOVERY DOCUMENT ",
  "authorization_endpoint_uri": "YOUR OAUTH2 PROVIDER'S ENDPOINT FOR AUTHORIZATION",
  "token_endpoint_uri": "YOUR OAUTH2 PROVIDER'S ENDPOINT FOR TOKEN",
  "registration_endpoint_uri": "xxx",
  "user_info_endpoint_uri": "YOUR OAUTH2 PROVIDER'S ENDPOINT FOR USER INFO",
  "https_required": true
}

NOTE: redirect_uri is exclusive with authorization_endpoint_uri, token_endpoint_uri and user_info_endpoint_uri

Google Sign-In for Android

The only need to run it is to place you client id in res/raw/google_signin.json like this

{
  "client_id": "YOUR CLIENT ID REGISTERED IN YOUR OAUTH2 PROVIDER"
}

License

Copyright Awesdroid 2019

This file is part of some open source application.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Contact: [email protected]

awesauthkt's People

Contributors

awesdroid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.