コード例 #1
0
ファイル: types.go プロジェクト: zhangbaitong/ark-ucenter
func (old *AuthorizeData) transfer() *osin.AuthorizeData {
	var authorizeData osin.AuthorizeData = osin.AuthorizeData{}
	authorizeData.Client = &old.Client
	authorizeData.Code = old.Code
	authorizeData.ExpiresIn = old.ExpiresIn
	authorizeData.Scope = old.Scope
	authorizeData.RedirectUri = old.RedirectUri
	authorizeData.State = old.State
	authorizeData.CreatedAt = old.CreatedAt
	authorizeData.UserData = old.UserData
	return &authorizeData
}
コード例 #2
0
ファイル: postgres.go プロジェクト: galeone/osin-storage
func (s *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
	var data osin.AuthorizeData
	var userData string
	var cid string
	row := s.db.QueryRow("SELECT client, code, expires_in, scope, redirect_uri, state, created_at, extra FROM authorize WHERE code=$1 LIMIT 1", code)
	if err := row.Scan(&cid, &data.Code, &data.ExpiresIn, &data.Scope, &data.RedirectUri, &data.State, &data.CreatedAt, &userData); err != nil {
		return nil, err
	}
	data.UserData = userData

	c, err := s.GetClient(cid)
	if err != nil {
		return nil, err
	}

	data.Client = c
	return &data, nil
}
コード例 #3
0
ファイル: authorization.go プロジェクト: koding/koding
func (store *MongoStorage) createAuthorizeData(copyFrom *AuthorizeData, osinData *osin.AuthorizeData) *osin.AuthorizeData {
	osinData.Code = copyFrom.Code
	osinData.ExpiresIn = copyFrom.ExpiresIn
	osinData.Scope = copyFrom.Scope
	osinData.RedirectUri = copyFrom.RedirectUri
	osinData.State = copyFrom.State
	osinData.CreatedAt = copyFrom.CreatedAt
	osinData.UserData = copyFrom.UserData

	client, err := store.GetClientWithUserData(copyFrom.UserData)
	if err != nil || client == nil {
		osinData.Client = &osin.DefaultClient{}
	} else {
		osinData.Client = client
	}

	return osinData
}
コード例 #4
0
ファイル: postgres.go プロジェクト: guitou4573/osin-storage
// LoadAuthorize looks up AuthorizeData by a code.
// Client information MUST be loaded together.
// Optionally can return error if expired.
func (s *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
	var data osin.AuthorizeData
	var extra string
	var cid string
	if err := s.db.QueryRow("SELECT client, code, expires_in, scope, redirect_uri, state, created_at, extra FROM authorize WHERE code=$1 LIMIT 1", code).Scan(&cid, &data.Code, &data.ExpiresIn, &data.Scope, &data.RedirectUri, &data.State, &data.CreatedAt, &extra); err == sql.ErrNoRows {
		return nil, pkg.ErrNotFound
	} else if err != nil {
		return nil, errors.New(err)
	}
	data.UserData = extra

	c, err := s.GetClient(cid)
	if err != nil {
		return nil, err
	}

	data.Client = c
	return &data, nil
}
コード例 #5
0
ファイル: mysql.go プロジェクト: guitou4573/osin-storage
// LoadAuthorize looks up AuthorizeData by a code.
// Client information MUST be loaded together.
// Optionally can return error if expired.
func (s *Storage) LoadAuthorize(code string) (*osin.AuthorizeData, error) {
	var data osin.AuthorizeData
	var extra string
	var cid string

	args := map[string]interface{}{
		"code": code,
	}
	nstmt, err := s.db.PrepareNamed("SELECT client, code, expires_in, scope, redirect_uri, state, created_at, extra FROM authorize WHERE code=:code LIMIT 1")
	if err := nstmt.QueryRowx(args).Scan(&cid, &data.Code, &data.ExpiresIn, &data.Scope, &data.RedirectUri, &data.State, &data.CreatedAt, &extra); err == sql.ErrNoRows {
		return nil, errors.New("not found")
	} else if err != nil {
		return nil, errors.New(err)
	}
	data.UserData = extra

	c, err := s.GetClient(cid)
	if err != nil {
		return nil, err
	}

	data.Client = c
	return &data, nil
}