Coder Social home page Coder Social logo

nickforall / exfirebaseauth Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 14.0 98 KB

๐Ÿ”ฅโš—๏ธ Handling and testing Firebase Auth tokens in Elixir

Home Page: https://hexdocs.pm/ex_firebase_auth

License: MIT License

Elixir 100.00%
auth elixir firebase google

exfirebaseauth's People

Contributors

alfietham avatar dependabot-preview[bot] avatar dependabot[bot] avatar joeljuca avatar juanazam avatar lucasavila00 avatar nickforall avatar rparcus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

exfirebaseauth's Issues

Add a method for generating custom tokens

https://firebase.google.com/docs/auth/admin/create-custom-tokens#create_custom_tokens_using_a_third-party_jwt_library

we would need people to supply their key/client email

along the lines of:

    key = JOSE.JWK.from_pem("private key")

    JOSE.JWT.sign(key, %{"alg" => "RS256"}, %{
      iss: "firebase client email",
      sub: "firebase client email",
      aud:
        "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
      iat: :os.system_time(:seconds),
      exp: :os.system_time(:seconds) + 3600,
      uid: firebase_user_id
    })
    |> JOSE.JWS.compact()
    |> elem(1)

Error when verifying tokens ("Public key retrieved from google was not found or could not be parsed")

Getting the same error consistently for last 30 minutes. First time using this library.

Version - {:ex_firebase_auth, "~> 0.5.1"}

ets table contains only one entry with following value -

iex(1)> :ets.first(ExFirebaseAuth.KeyStore)
"6a4f87ff5d93fa6ea03e5c6e88eea0acd2a232a9"
iex(2)> :ets.last(ExFirebaseAuth.KeyStore)
"6a4f87ff5d93fa6ea03e5c6e88eea0acd2a232a9"
iex(3)> :ets.lookup(ExFirebaseAuth.KeyStore, "6a4f87ff5d93fa6ea03e5c6e88eea0acd2a232a9")
[
  {"6a4f87ff5d93fa6ea03e5c6e88eea0acd2a232a9",
   %JOSE.JWK{
     fields: %{},
     keys: :undefined,
     kty: {:jose_jwk_kty_rsa,
      {:RSAPublicKey,
       26683466267166000117937282941287368499188964267704350320016815060755186299190334552341359030182847862883650390995706932990206917504303874597159717626156857776530120286608824298039026662712309062585296391513994028930201376912224740158628136408547035523323040966599847393117788904610391693639428199426775371439187431710883575502972086796633627213970033547315970319396410708150818633921757026450722384908347116277890243025314192440036812929920627983552722832658264926504359043778585873454116991087894748041249472749584754467425019137143154494316545575161017698890108258608397227982398909111303817013085192016995952648177,
       65537}}
   }}
]

Verify token returns

{:error, "Public key retrieved from google was not found or could not be parsed"}

Originally posted by @akashvibhute in #13 (comment)

Intermittent error when verifying tokens ("Public key retrieved from google was not found or could not be parsed")

Hello Nick!

Thanks for writing and sharing ExFirebaseAuth! I'm using it on my project, and when I try to parse a Firebase token with ExFirebaseAuth.Token.verify_token/1, I get the following error:

{:error,
 "Public key retrieved from google was not found or could not be parsed"}

This is an intermittent scenario. It works sometimes, but once in a while I get this error. I'm not sure if it's an issue with my application, my build, or the library itself (I'm doing using anything other than decoding Firebase tokens, and I've properly configured the library as per docs says).

What could I do to fix, debug, or handle this kind of error?

[Feature Request] Don't prevent applications from starting up if credentials cannot be fetched

First of all, thanks @Nickforall for the awesome library.
I found the source code really amazing, an awesome source of good elixir :)

I would like to request changes to the behavior of the library, so that it no longer prevents app initialization if it couldn't fetch the credentials. Somewhere along these lines should retry or ignore such errors.

In my current project I use firebase auth for a minor feature, so if it fails, I would like everything else to continue to work.

Also, I use this library behind a layer of custom code, and at test time I don't actually test against this library. If I turn my internet off then my tests won't run anymore.

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.