View object_pool_part1.go
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) |
View middleware.go
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 |
View encode_jwt.go
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 |
View parse_jwt.go
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 |
View get.go
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 { |
View create.go
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() |
View handlers.go
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) |
View key.go
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 { |
View root.go
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{ |
View encrypt.go
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
import ( | |
"crypto/aes" | |
"crypto/cipher" | |
"crypto/rand" | |
"encoding/hex" | |
"os" | |
) | |
// Encrypt will encrypt a raw string to | |
// an encrypted value |
NewerOlder