All Projects → alekcz → charmander

alekcz / charmander

Licence: EPL-1.0 license
A set of libraries to make working with firebase easier in clojure

Programming Languages

clojure
4091 projects

Projects that are alternatives of or similar to charmander

DashboardHeroLite
The easiest way to build an admin dashboard for your SaaS. Fully functional user management, UI and routing.
Stars: ✭ 34 (+3.03%)
Mutual labels:  firebase-auth
vuefire-auth
Vue2-Auth-Email Verification with Firebase🔥
Stars: ✭ 29 (-12.12%)
Mutual labels:  firebase-auth
BirthdayReminder
Open source Android application which keeps track of and reminds users of their loved ones birthdays. View on the PlayStore here: https://play.google.com/store/apps/details?id=website.julianrosser.birthdays
Stars: ✭ 29 (-12.12%)
Mutual labels:  firebase-auth
BooksApp
Book selling application with MVVM (Model, View, ViewModel), LiveData, DataBinding, Retrofit, Room Database, Navigation Component(NavGraph, BottomNav), ViewPager2 in TabLayout, SearchView, Vertical Adapter(BestSellers) and Horizontal Adapter(All Books) with ConcatAdapter for Main Screen, Firebase Auth, SearchView in Adapter, Picasso, Lottie, Ani…
Stars: ✭ 53 (+60.61%)
Mutual labels:  firebase-auth
Gmail-Clone
A Gmail Clone which built with ReactJS and Redux. You can sign in with your Google Account, compose a new e-mail and send realtime emails to the project.
Stars: ✭ 48 (+45.45%)
Mutual labels:  firebase-auth
firebase-id-tokens-verifier
Code snippet to show how to verify Firebase ID tokens using Ruby
Stars: ✭ 32 (-3.03%)
Mutual labels:  firebase-auth
platform
Community platform for dancers
Stars: ✭ 30 (-9.09%)
Mutual labels:  firebase-auth
ChatApp
Chat app based on Firebase tools.
Stars: ✭ 88 (+166.67%)
Mutual labels:  firebase-auth
Pure
Pure is a free social networking App. it is simple, reliable and it makes it easy to keep in touch with your friends and family. Pure works across mobile devices even on slow internet connections.
Stars: ✭ 28 (-15.15%)
Mutual labels:  firebase-auth
logregform-android
Login and registration form for Android (IceCream Sandwich+) with additional features, enchancement and dynamic GUI.
Stars: ✭ 25 (-24.24%)
Mutual labels:  firebase-auth
amrita-resource
An android App which contains some PDFs of classes notes of particular department of particular subject 🎓
Stars: ✭ 20 (-39.39%)
Mutual labels:  firebase-auth
club penguin game
A simple 2D multiplayer online game built using Flutter and Flame engine
Stars: ✭ 65 (+96.97%)
Mutual labels:  firebase-auth
firebase-auth-dotnet
A .NET API client for Firebase Rest Authentication API that follows Google's API spec as precisely as possible.
Stars: ✭ 16 (-51.52%)
Mutual labels:  firebase-auth
ResDelivery-Hilt-Coroutines-Mvvm-Single-Activity
This is a Sample Single Activity App (Multi Fragments) that uses Dagger-Hilt, Coroutines Flows, Paging 3 & Mvvm Clean Architecture
Stars: ✭ 28 (-15.15%)
Mutual labels:  firebase-auth
Whizzz-The-ChatApp
Whizzz is a real-time, one-to-one Android chat application made using Firebase, a beautiful user interface, and a push-notification feature.
Stars: ✭ 66 (+100%)
Mutual labels:  firebase-auth
vue-blog
Book blog
Stars: ✭ 31 (-6.06%)
Mutual labels:  firebase-auth
flutter-fitness-app
Fitness app using Flutter
Stars: ✭ 30 (-9.09%)
Mutual labels:  firebase-auth
firebaseauth
Firebase authentication library - a node js wrapper around the Firebase REST API
Stars: ✭ 43 (+30.3%)
Mutual labels:  firebase-auth
firebase
Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
Stars: ✭ 36 (+9.09%)
Mutual labels:  firebase-auth
IoT-Modelling-Tool
IoT Modelling Tool is a platform which allows users to have their own devices and components modeled in order to represent and manage a physical environment.
Stars: ✭ 16 (-51.52%)
Mutual labels:  firebase-auth

Charmander

A clojure library to make working with firebase easier

master codecov

Clojars Project

Why?

  • Authentication, email verification and password resets are tedious and hard.
  • Auth0 gets pricey as you scale
  • Firebase auth has a fixed cost of 0 (for now)

Usage

[alekcz/charmander "1.0.3"]

;; In your ns statement:
(ns my.ns
  (:require [charmander.core :as charm]
            [charmander.admin :as charm-admin]
            [charmander.firestore :as charm-firestore]))

API

  • Token API

    • validate-token
  • Admin API

    • init
    • create-user
    • delete-user
    • get-user
    • get-user-by-email
    • get-user-by-phone-number
    • set-user-email
    • set-user-password
    • set-user-phone-number
    • set-user-display-name
    • set-user-photo-url
    • generate-email-verification-link
    • generate-password-reset-link
  • Firestore API

    • create-document
    • add-document-to-collection
    • get-document
    • get-document-and-subcollections
    • get-collection
    • set-document
    • update-document
    • delete-document

Validating tokens

Validates firebase tokens. Validating tokens doesn't require an admin or service account.

(charm/validate-token "firebase-project-id" fresh-token)  
;;{
;;	:projectid "firebase-project-id", 
;;	:uid "uid", 
;;	:email "[email protected]", 
;;	:email_verified false, 
;;	:sign_in_provider "password", 
;;	:exp 0000000000, 
;;	:auth_time 0000000000
;;}

(charm/validate-token "firebase-project-id" stale-token)
;; nil

(charm/validate-token "wrong-firebase-project-id" fresh-token)
;; nil

(charm/validate-token "(.*)-project-ids" fresh-token)
;;{
;;	:projectid "multiple-project-ids", 
;;	:uid "uid", 
;;	:email "[email protected]", 
;;	:email_verified false, 
;;	:sign_in_provider "password", 
;;	:exp 0000000000, 
;;	:auth_time 0000000000
;;}

Admin

Manages user data and authentication using your firebase admin or service account credentials using the email/password sign-in provider. At the moment only one firebase app can be used at a time.

The Admin API is based on the Java Firebase Admin SDK v6.8.0

Initializing your admin account

  1. Get the json file containing your creditials by following the instruction here https://firebase.google.com/docs/admin/setup

  2. Enable the email/password sign-in provider.

  3. Set the GOOGLE_CLOUD_PROJECT environment to the id of your project

  4. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the contents of your json key file. (Sometimes it may be necessary to wrap the key contents in single quotes to escape all the special characters within it. e.g. GOOGLE_APPLICATION_CREDENTIALS='contents-of-json')

  5. initialize the admin sdk in charmander

(charm-admin/init)  

Managing user accounts

The admin api only allows the creating of users using the email/password sign-in provider.

(charm-admin/create-user "[email protected]" "superstrong6characterpassword")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url nil
;;    :phone-number nil
;;    :display-name nil
;;    :disabled false
;;}

(charm-admin/get-user "vMnMJvS28kWr5pb6sByHULMLelJ3")  
;;{   
;;    :email [email protected]
;;    :email-verified true
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number nil
;;    :display-name emailer
;;    :disabled false
;;}

(charm-admin/get-user-by-email "[email protected]")  
;;{   
;;    :email [email protected]
;;    :email-verified true
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number nil
;;    :display-name emailer
;;    :disabled false
;;}

(charm-admin/set-user-email "vMnMJvS28kWr5pb6sByHULMLelJ3" "[email protected]")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number nil
;;    :display-name emailer
;;    :disabled false
;;}

(charm-admin/set-user-password "vMnMJvS28kWr5pb6sByHULMLelJ3" "5tr0ngp455w0rd")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number nil
;;    :display-name emailer
;;    :disabled false
;;}

(charm-admin/set-user-phone-number "vMnMJvS28kWr5pb6sByHULMLelJ3" "0800123123")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number 0800123123
;;    :display-name emailer
;;    :disabled false
;;}

(charm-admin/set-user-display-name "vMnMJvS28kWr5pb6sByHULMLelJ3" "Tony Hawk")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://avatars0.githubusercontent.com/u/11717556?s=460&v=4
;;    :phone-number nil
;;    :display-name Tony Hawk
;;    :disabled false
;;}

(charm-admin/set-user-photo-url "vMnMJvS28kWr5pb6sByHULMLelJ3" "https://en.wikipedia.org/wiki/Tony_Hawk#/media/File:Skater_Tony_Hawk.jpg")  
;;{   
;;    :email [email protected]
;;    :email-verified false
;;    :uid vMnMJvS28kWr5pb6sByHULMLelJ3
;;    :provider-id firebase
;;    :photo-url https://en.wikipedia.org/wiki/Tony_Hawk#/media/File:Skater_Tony_Hawk.jpg
;;    :phone-number nil
;;    :display-name Tony Hawk
;;    :disabled false
;;}

(charm-admin/generate-email-verification-link "[email protected]")  
;; https://alekcz-dev.firebaseapp.com/__/auth/action?mode=verifyEmail&oobCode=d6uX0gzOuvnZLAwfk8HKxLYrRUCUaBnrzwDgFdzfDhgAAAFprFHVmQ&apiKey=AIz0000yaVaaa512312YL_lffaf311da333211TBp_QPFqvda2e1daw&lang=en


(charm-admin/generate-password-reset-link "[email protected]")  
;; https://alekcz-dev.firebaseapp.com/__/auth/action?mode=resetPassword&oobCode=viRcZqjCqxN6eYYmkQGY2fCZjU4RDKuNhysok83ghSEAAAFprFVwJg&apiKey=AIz0000yaVaaa512312YL_lffaf311da333211TBp_QPFqvda2e1daww&lang=en

Working with Firestore (Alpha)

The API allows for CRUD operation on firestore.

(charm-firestore/create-document "collection" "document" {:field1 "field1" :field2 "field2"})  
;;nil

(charm-firestore/add-document-to-collection "path/to/collection" {:field1 "field1" :field2 "field2"})  
;;  { :id "document",
;;    :data {
;;          :name "Document",
;;          :subcollections ()
;;     }
;;  }

(charm-firestore/push-document-to-collection "path/to/collection" {:field1 "field1" :field2 "field2"})  
;; nil
;; To allow increased through put this writes to firebase but gives not feedback.

(charm-firestore/get-document "path/to/collection" "document")  
;;  { :id "document",
;;    :data {
;;          :name "Document",
;;          :subcollections
;;           ({:id "subcollection1", :path "collection/document/subcollection1"}
;;            {:id "subcollection2", :path "collection/document/subcollection2"}
;;            {:id "subcollection3", :path "collection/document/subcollection2"})
;;     }
;;  }

(charm-firestore/get-document-and-subcollections "path/to/collection" "document")  
;;  { :id "document",
;;    :data {
;;          :name "Document",
;;          :subcollections
;;           ({:id "subcollection1", 
;;             :path "collection/document/subcollection1"
;;             :data ({:id "9AMN2yNG3J9GvtTPMxxy", :data {:name "SubdocumentA"}})}
;;            {:id "subcollection2", 
;;             :path "collection/document/subcollection1"
;;             :data ({:id "6223N2yNG3J9GvtTPMxxy", :data {:name "SubdocumentB"}})})
;;             
;;     }
;;  }

(charm-firestore/get-collection "path/to/collection")  
;;     ({:id "collectionA", 
;;       :path "collection/document/collectionA"
;;       :data ({:id "6223N2yNG3J9GvtTPMxxy", :data {:name "SubdocumentP"}}
;;              {:id "6223N2yNG3J9GvtTPMxxy", :data {:name "SubdocumentQ"}}))})

(charm-firestore/set-document "path/to/document-to-be-overwritten" {:field1 "field1" :field2 "field2"})  
;;nil

(charm-firestore/update-document "path/to/document-to-be-updated" {:field1 "field1" :field2 "field2"})  
;;nil

(charm-firestore/delete-document "path/to/document-to-be-delete")  
;;nil

Next steps

  • Increase efficiency
  • Look into core.async for public key refresh
  • Build up API

License

Copyright © 2019 Alexander Oloo

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].