summaryrefslogtreecommitdiff
path: root/cmd/ponzu/vendor/github.com/nilslice
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/ponzu/vendor/github.com/nilslice')
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/email/LICENSE21
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/email/README.md51
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/email/email.go119
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/email/email_test.go19
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/jwt/LICENSE19
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/jwt/README.md43
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go40
-rw-r--r--cmd/ponzu/vendor/github.com/nilslice/jwt/jwt.go204
8 files changed, 0 insertions, 516 deletions
diff --git a/cmd/ponzu/vendor/github.com/nilslice/email/LICENSE b/cmd/ponzu/vendor/github.com/nilslice/email/LICENSE
deleted file mode 100644
index 6ac9da6..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/email/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2016 Steve Manuel
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/cmd/ponzu/vendor/github.com/nilslice/email/README.md b/cmd/ponzu/vendor/github.com/nilslice/email/README.md
deleted file mode 100644
index 190c61f..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/email/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-## Email
-
-I needed a way to send email from a [Ponzu](https://ponzu-cms.org) installation
-running on all kinds of systems without shelling out. `sendmail` or `postfix` et
-al are not standard on all systems, and I didn't want to force users to add API
-keys from a third-party just to send something like an account recovery email.
-
-### Usage:
-`$ go get github.com/nilslice/email`
-
-```go
-package main
-
-import (
- "fmt"
- "github.com/nilslice/email"
-)
-
-func main() {
- msg := email.Message{
- To: "you@server.name", // do not add < > or name in quotes
- From: "me@server.name", // do not add < > or name in quotes
- Subject: "A simple email",
- Body: "Plain text email body. HTML not yet supported, but send a PR!",
- }
-
- err := msg.Send()
- if err != nil {
- fmt.Println(err)
- }
-}
-
-```
-
-### Under the hood
-`email` looks at a `Message`'s `To` field, splits the string on the @ symbol and
-issues an MX lookup to find the mail exchange server(s). Then it iterates over
-all the possibilities in combination with commonly used SMTP ports for non-SSL
-clients: `25, 2525, & 587`
-
-It stops once it has an active client connected to a mail server and sends the
-initial information, the message, and then closes the connection.
-
-Currently, this doesn't support any additional headers or `To` field formatting
-(the recipient's email must be the only string `To` takes). Although these would
-be fairly strightforward to implement, I don't need them yet.. so feel free to
-contribute anything you find useful.
-
-#### Warning
-Be cautious of how often you run this locally or in testing, as it's quite
-likely your IP will be blocked/blacklisted if it is not already. \ No newline at end of file
diff --git a/cmd/ponzu/vendor/github.com/nilslice/email/email.go b/cmd/ponzu/vendor/github.com/nilslice/email/email.go
deleted file mode 100644
index 15f0a49..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/email/email.go
+++ /dev/null
@@ -1,119 +0,0 @@
-package email
-
-import (
- "fmt"
- "net"
- "net/smtp"
- "strings"
-)
-
-// Message creates a email to be sent
-type Message struct {
- To string
- From string
- Subject string
- Body string
-}
-
-var (
- ports = []int{25, 2525, 587}
-)
-
-// Send sends a message to recipient(s) listed in the 'To' field of a Message
-func (m Message) Send() error {
- if !strings.Contains(m.To, "@") {
- return fmt.Errorf("Invalid recipient address: <%s>", m.To)
- }
-
- host := strings.Split(m.To, "@")[1]
- addrs, err := net.LookupMX(host)
- if err != nil {
- return err
- }
-
- c, err := newClient(addrs, ports)
- if err != nil {
- return err
- }
-
- err = send(m, c)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func newClient(mx []*net.MX, ports []int) (*smtp.Client, error) {
- for i := range mx {
- for j := range ports {
- server := strings.TrimSuffix(mx[i].Host, ".")
- hostPort := fmt.Sprintf("%s:%d", server, ports[j])
- client, err := smtp.Dial(hostPort)
- if err != nil {
- if j == len(ports)-1 {
- return nil, err
- }
-
- continue
- }
-
- return client, nil
- }
- }
-
- return nil, fmt.Errorf("Couldn't connect to servers %v on any common port.", mx)
-}
-
-func send(m Message, c *smtp.Client) error {
- if err := c.Mail(m.From); err != nil {
- return err
- }
-
- if err := c.Rcpt(m.To); err != nil {
- return err
- }
-
- msg, err := c.Data()
- if err != nil {
- return err
- }
-
- if m.Subject != "" {
- _, err = msg.Write([]byte("Subject: " + m.Subject + "\r\n"))
- if err != nil {
- return err
- }
- }
-
- if m.From != "" {
- _, err = msg.Write([]byte("From: <" + m.From + ">\r\n"))
- if err != nil {
- return err
- }
- }
-
- if m.To != "" {
- _, err = msg.Write([]byte("To: <" + m.To + ">\r\n"))
- if err != nil {
- return err
- }
- }
-
- _, err = fmt.Fprint(msg, m.Body)
- if err != nil {
- return err
- }
-
- err = msg.Close()
- if err != nil {
- return err
- }
-
- err = c.Quit()
- if err != nil {
- return err
- }
-
- return nil
-}
diff --git a/cmd/ponzu/vendor/github.com/nilslice/email/email_test.go b/cmd/ponzu/vendor/github.com/nilslice/email/email_test.go
deleted file mode 100644
index 3576a79..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/email/email_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package email
-
-import (
- "testing"
-)
-
-func TestSend(t *testing.T) {
- m := Message{
- To: "",
- From: "",
- Subject: "",
- Body: "",
- }
-
- err := m.Send()
- if err != nil {
- t.Fatal("Send returned error:", err)
- }
-}
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/LICENSE b/cmd/ponzu/vendor/github.com/nilslice/jwt/LICENSE
deleted file mode 100644
index f67119e..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/jwt/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (C) 2015 Steve Manuel <stevenhmanuel@gmail.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md b/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md
deleted file mode 100644
index a384dd1..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/jwt/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# JWT
-
-### Usage
- $ go get github.com/nilslice/jwt
-
-package jwt provides methods to create and check JSON Web Tokens. It only implements HMAC 256 encryption and has a very small footprint, ideal for simple usage when authorizing clients
-
-```go
- package main
-
- import (
- auth "github.com/nilslice/jwt"
- "fmt"
- "net/http"
- "strings"
- )
-
- func main() {
- http.HandleFunc("/auth/new", func(res http.ResponseWriter, req *http.Request) {
- claims := map[string]interface{}{"exp": time.Now().Add(time.Hour * 24).Unix()}
- token, err := auth.New(claims)
- if err != nil {
- http.Error(res, "Error", 500)
- return
- }
- res.Header().Add("Authorization", "Bearer "+token)
-
- res.WriteHeader(http.StatusOK)
- })
-
- http.HandleFunc("/auth", func(res http.ResponseWriter, req *http.Request) {
- userToken := strings.Split(req.Header.Get("Authorization"), " ")[1]
-
- if auth.Passes(userToken) {
- fmt.Println("ok")
- } else {
- fmt.Println("no")
- }
- })
-
- http.ListenAndServe(":8080", nil)
- }
-```
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go b/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go
deleted file mode 100644
index aa9a5c8..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/jwt/doc.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Package jwt provides methods to create and check JSON Web Tokens (JWT). It only implements HMAC 256 encryption and has a very small footprint, ideal for simple usage when authorizing clients
-/*
-
- package main
-
- import (
- auth "github.com/nilslice/jwt"
- "fmt"
- "net/http"
- "strings"
- "time"
- )
-
- func main() {
- http.HandleFunc("/auth/new", func(res http.ResponseWriter, req *http.Request) {
- claims := map[string]interface{}{"exp": time.Now().Add(time.Hour * 24).Unix()}
- token, err := auth.New(claims)
- if err != nil {
- http.Error(res, "Error", 500)
- return
- }
- res.Header().Add("Authorization", "Bearer "+token)
-
- res.WriteHeader(http.StatusOK)
- })
-
- http.HandleFunc("/auth", func(res http.ResponseWriter, req *http.Request) {
- userToken := strings.Split(req.Header.Get("Authorization"), " ")[1]
-
- if auth.Passes(userToken) {
- fmt.Println("ok")
- } else {
- fmt.Println("no")
- }
- })
-
- http.ListenAndServe(":8080", nil)
- }
-*/
-package jwt
diff --git a/cmd/ponzu/vendor/github.com/nilslice/jwt/jwt.go b/cmd/ponzu/vendor/github.com/nilslice/jwt/jwt.go
deleted file mode 100644
index 6d7eaa3..0000000
--- a/cmd/ponzu/vendor/github.com/nilslice/jwt/jwt.go
+++ /dev/null
@@ -1,204 +0,0 @@
-package jwt
-
-import (
- "crypto/hmac"
- "crypto/sha256"
- "encoding/base64"
- "encoding/json"
- "errors"
- "fmt"
- "strings"
-)
-
-var (
- privateKey = []byte("")
- defaultHeader = header{Typ: "JWT", Alg: "HS256"}
- registeredClaims = []string{"iss", "sub", "aud", "exp", "nbf", "iat", "jti"}
-)
-
-type header struct {
- Typ string `json:"typ"`
- Alg string `json:"alg"`
-}
-
-type payload map[string]interface{}
-
-type encoded struct {
- token string
-}
-type decoded struct {
- header string
- payload string
-}
-
-type signedDecoded struct {
- decoded
- signature string
-}
-
-func newEncoded(claims map[string]interface{}) (encoded, error) {
- header, err := json.Marshal(defaultHeader)
- if err != nil {
- return encoded{}, err
- }
-
- for _, claim := range registeredClaims {
- if _, ok := claims[claim]; !ok {
- claims[claim] = nil
- }
- }
-
- payload, err := json.Marshal(claims)
- if err != nil {
- return encoded{}, err
- }
-
- d := decoded{header: string(header), payload: string(payload)}
-
- d.encodeInternal()
- signed, err := d.sign()
- if err != nil {
- return encoded{}, err
- }
-
- token := signed.token()
- e := encoded{token: token}
- return e, nil
-}
-
-func newDecoded(token string) (decoded, error) {
- e := encoded{token: token}
- d, err := e.parseToken()
- if err != nil {
- return d, nil
- }
-
- return d, nil
-}
-
-func encodeToString(src []byte) string {
- return base64.RawURLEncoding.EncodeToString(src)
-}
-
-func (d decoded) getHeader() []byte {
- return []byte(d.header)
-}
-
-func (d decoded) getPayload() []byte {
- return []byte(d.payload)
-}
-
-func (sd signedDecoded) getSignature() []byte {
- return []byte(sd.signature)
-}
-
-func (d *decoded) encodeInternal() {
- d.header = encodeToString(d.getHeader())
- d.payload = encodeToString(d.getPayload())
-}
-
-func (d decoded) dot(internals ...string) string {
- return strings.Join(internals, ".")
-}
-
-func (d *decoded) sign() (signedDecoded, error) {
- if d.header == "" || d.payload == "" {
- return signedDecoded{}, errors.New("Missing header or payload on Decoded")
- }
-
- unsigned := d.dot(d.header, d.payload)
-
- hash := hmac.New(sha256.New, privateKey)
- _, err := hash.Write([]byte(unsigned))
- if err != nil {
- return signedDecoded{}, err
- }
-
- signed := signedDecoded{decoded: *d}
- signed.signature = encodeToString(hash.Sum(nil))
-
- return signed, nil
-}
-
-func (sd signedDecoded) token() string {
- return fmt.Sprintf("%s.%s.%s", sd.getHeader(), sd.getPayload(), sd.getSignature())
-}
-
-func (sd signedDecoded) verify(enc encoded) bool {
- if sd.token() == enc.token {
- return true
- }
- return false
-}
-
-func (e encoded) parseToken() (decoded, error) {
- parts := strings.Split(e.token, ".")
- if len(parts) != 3 {
- return decoded{}, errors.New("Error: incorrect # of results from string parsing")
- }
-
- d := decoded{
- header: parts[0],
- payload: parts[1],
- }
-
- return d, nil
-}
-
-// New returns a token (string) and error. The token is a fully qualified JWT to be sent to a client via HTTP Header or other method. Error returned will be from the newEncoded unexported function.
-func New(claims map[string]interface{}) (string, error) {
- enc, err := newEncoded(claims)
- if err != nil {
- return "", err
- }
-
- return enc.token, nil
-}
-
-// Passes returns a bool indicating whether a token (string) provided has been signed by our server. If true, the client is authenticated and may proceed.
-func Passes(token string) bool {
- dec, err := newDecoded(token)
- if err != nil {
- // may want to log some error here so we have visibility
- // intentionally simplifying return type to bool for ease
- // of use in API. Caller should only do `if auth.Passes(str) {}`
- return false
- }
- signed, err := dec.sign()
- if err != nil {
- return false
- }
-
- return signed.verify(encoded{token: token})
-}
-
-// GetClaims() returns a token's claims, allowing
-// you to check the values to make sure they match
-func GetClaims(token string) map[string]interface{} {
- // decode the token
- dec, err := newDecoded(token)
- if err != nil {
- return nil
- }
-
- // base64 decode payload
- payload, err := base64.RawURLEncoding.DecodeString(dec.payload)
- if err != nil {
- return nil
- }
-
- dst := map[string]interface{}{}
- err = json.Unmarshal(payload, &dst)
- if err != nil {
- return nil
- }
-
- return dst
-
-}
-
-// Secret is a helper function to set the unexported privateKey variable used when signing and verifying tokens.
-// Its argument is type []byte since we expect users to read this value from a file which can be excluded from source code.
-func Secret(key []byte) {
- privateKey = key
-}