Giter Site home page Giter Site logo

fireauth's People

Contributors

creack avatar hsinhoyeh avatar mrgossett avatar sinmetal avatar zabawaba99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar

fireauth's Issues

Support Firebase 3 Authentication

When attempting an auth from a generated token by fire auth I am getting:
FIRAuthErrorDomain Code=17000 "The custom token format is incorrect. Please check the documentation."

Fix Build/Code Coverage

  • Configure travis to build this repo
  • Configure Coveralls to build repo and report code coverage

the behavior of sign() seems wrong

please noted that the behavior of h.Write([]byte{...}) and h.Sum([]byte{...}) are different,
you can check this example: https://play.golang.org/p/y7S52DdL_T

in Sum(data), it actually appends the checksum AFTER the byte data.
https://golang.org/src/crypto/sha256/sha256.go?s=1643:1663#L128

however, the following code snippet works fine for me

@@ -136,5 +138,7 @@ func encode(data []byte) string {
 }
 func sign(message, secret string) string {
-       return encode(hmac.New(sha256.New, []byte(secret)).Sum([]byte(message)))
+       h := hmac.New(sha256.New, []byte(secret))
+       h.Write([]byte(message))
+       return encode(h.Sum(nil))
 }

I would like to send a PR, any concerns?

Option to automatically regenerate expired tokens

Firebase tokens expire 24 hours after they're created, unless an explicit expiration is set. Fireauth can anticipate the expiration of any token it generates. It would be useful if fireauth also had a mechanism to generate new tokens on-demand (to replace an expired token).

This might be accomplished by providing something like func (*Generator) CreateTokenWithRefresh(Data, *Option) (string, chan string, error) which returns a generated token along with a chan string that will publish a new token when the previous token expires. Implementers would then end up doing something like this:

auth := fireauth.New(mySecret)

token, refresher, _ := auth.CreateTokenWithRefresh(data, options)

// later on...
select {
case refreshedToken <- refresher:
    token = refreshedToken
default:
}
// carry on using token

A possible (and untested) implementation of CreateTokenWithRefresh:

func (t *Generator) CreateTokenWithRefresh(data Data, options *Option) (string, chan string, error) {
    token, err := t.CreateToken(data, options)
    if err != nil {
        return "", nil, err
    }

    c := make(chan string)
    duration := time.Unix(options.Expiration, 0).Sub(time.Now())
    ticker := time.NewTicker(duration)

    go func() {
        for _ = range <-ticker.C {
            newToken, err := t.CreateToken(data, options)
            if err != nil {
                close(c)
                ticker.Stop()
                return
            }
            c <- newToken
        }
    }()

    return token, c, nil
}

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.