This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Basic key operators to query the JSON objects : | |
# #> : Get the JSON object at that path (if you need to do something fancy) | |
# -> : Get the JSON object at that path (if you don't) | |
# ->> : Get the JSON object at that path as text | |
# {obj, n} : Get the nth item in that object | |
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE | |
# Date | |
# date before today |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Object interface { | |
Close() | |
} | |
type Factory func() (Object, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package goliauth | |
import ( | |
"fmt" | |
"net/http" | |
"strings" | |
) | |
// AuthenticateJWTMiddleware wraps AuthenticateJWTToken to provide middleware | |
// this is just an example to show how it can be used as a middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package goliauth | |
import ( | |
"fmt" | |
jwt "github.com/dgrijalva/jwt-go" | |
) | |
// EncodeJWT serialize data into a jwt token using a secret | |
// This secret must match with the client's secret who's generating the token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package goliauth | |
import ( | |
"fmt" | |
jwt "github.com/dgrijalva/jwt-go" | |
) | |
// Claims is an alias for MapClaims | |
type Claims = jwt.MapClaims |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app | |
import ( | |
"encoding/hex" | |
"fmt" | |
"github.com/omnisyle/goliauth" | |
) | |
func GetApp(publicKey, dbURL string) *App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app | |
import ( | |
"fmt" | |
"github.com/omnisyle/goliauth" | |
) | |
func CreateApp(name, dbURL string) *App { | |
publicKey := goliauth.NewRandomKey() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func createApp(cmd *cobra.Command, args []string) { | |
appName := args[0] | |
keyPair := app.CreateApp(appName, db) | |
printResult(keyPair) | |
} | |
func getApp(cmd *cobra.Command, args []string) { | |
publicKey := args[0] | |
keyPair := app.GetApp(publicKey, db) | |
printResult(keyPair) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cmd | |
import ( | |
"fmt" | |
"github.com/omnisyle/goliauth" | |
"github.com/spf13/cobra" | |
) | |
func keyCmd() *cobra.Command { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cmd | |
import ( | |
"fmt" | |
"os" | |
"github.com/spf13/cobra" | |
) | |
var rootCmd = &cobra.Command{ |
NewerOlder