示例#1
0
func (p *prov) Exchange(code string) (provider.Session, error) {
	if code != "code" {
		return nil, errors.New("Code not 'code'")
	}
	return &provider.DefaultSession{
		RemoteSubject: "remote-id",
		Token:         &oauth2.Token{},
	}, nil
}
示例#2
0
文件: jwt.go 项目: thanzen/hydra
// Create, sign, and return a token.
func (j *JWT) SignToken(claims map[string]interface{}, header map[string]interface{}) (string, error) {
	if _, ok := header["alg"]; ok {
		return "", errors.New("You may not override the alg header key.")
	}

	if _, ok := header["typ"]; ok {
		return "", errors.New("You may not override the typ header key.")
	}

	token := jwt.New(jwt.SigningMethodRS256)
	token.Claims = claims
	token.Header = merge(token.Header, header)
	ecdsaKey, err := jwt.ParseRSAPrivateKeyFromPEM(j.privateKey)
	if err != nil {
		return "", err
	}
	return token.SignedString(ecdsaKey)
}
示例#3
0
文件: account.go 项目: thanzen/hydra
package account

import "github.com/ory-am/hydra/Godeps/_workspace/src/github.com/go-errors/errors"

var ErrNotFound = errors.New("Not found")

type Account interface {
	GetID() string
	GetPassword() string
	GetEmail() string
	GetData() string
}

type DefaultAccount struct {
	ID       string `json:"id"`
	Email    string `json:"email"`
	Password string `json:"-"`
	Data     string `json:"data"`
}

func (a *DefaultAccount) GetID() string {
	return a.ID
}

func (a *DefaultAccount) GetPassword() string {
	return a.Password
}

func (a *DefaultAccount) GetEmail() string {
	return a.Email
}