Skip to content

Commit

Permalink
vendor: Remove ORY Hydra dependency (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: arekkas <[email protected]>
  • Loading branch information
aeneasr authored Aug 31, 2018
1 parent 9a45107 commit d487344
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
27 changes: 2 additions & 25 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions policy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"github.com/julienschmidt/httprouter"
"github.com/ory/herodot"
"github.com/ory/hydra/pkg"
"github.com/ory/ladon"
"github.com/ory/pagination"
"github.com/pborman/uuid"
Expand Down Expand Up @@ -143,7 +142,7 @@ func (h *Handler) Get(w http.ResponseWriter, r *http.Request, ps httprouter.Para
policy, err := h.Manager.Get(ps.ByName("id"))
if err != nil {
if err.Error() == "Not found" {
h.H.WriteError(w, r, errors.WithStack(pkg.ErrNotFound))
h.H.WriteError(w, r, errors.WithStack(&herodot.ErrorNotFound))
return
}
h.H.WriteError(w, r, errors.WithStack(err))
Expand Down
4 changes: 2 additions & 2 deletions role/manager_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package role
import (
"sync"

"github.com/ory/hydra/pkg"
"github.com/ory/herodot"
"github.com/ory/pagination"
"github.com/pborman/uuid"
"github.com/pkg/errors"
Expand Down Expand Up @@ -54,7 +54,7 @@ func (m *MemoryManager) CreateRole(r *Role) error {

func (m *MemoryManager) GetRole(id string) (*Role, error) {
if r, ok := m.Roles[id]; !ok {
return nil, errors.WithStack(pkg.ErrNotFound)
return nil, errors.WithStack(&herodot.ErrorNotFound)
} else {
return &r, nil
}
Expand Down
8 changes: 4 additions & 4 deletions role/manager_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"fmt"

"github.com/jmoiron/sqlx"
"github.com/ory/hydra/pkg"
"github.com/ory/herodot"
"github.com/pborman/uuid"
"github.com/pkg/errors"
"github.com/rubenv/sql-migrate"
Expand Down Expand Up @@ -102,7 +102,7 @@ func (m *SQLManager) GetRole(id string) (*Role, error) {

var q []string
if err := m.DB.Select(&q, m.DB.Rebind(fmt.Sprintf("SELECT member from %s WHERE role_id = ?", m.TableMember)), found); err == sql.ErrNoRows {
return nil, errors.WithStack(pkg.ErrNotFound)
return nil, errors.WithStack(&herodot.ErrorNotFound)
} else if err != nil {
return nil, errors.WithStack(err)
}
Expand Down Expand Up @@ -164,7 +164,7 @@ func (m *SQLManager) RemoveRoleMembers(role string, subjects []string) error {
func (m *SQLManager) FindRolesByMember(member string, limit, offset int) ([]Role, error) {
var ids []string
if err := m.DB.Select(&ids, m.DB.Rebind(fmt.Sprintf("SELECT role_id from %s WHERE member = ? GROUP BY role_id ORDER BY role_id LIMIT ? OFFSET ?", m.TableMember)), member, limit, offset); err == sql.ErrNoRows {
return nil, errors.WithStack(pkg.ErrNotFound)
return nil, errors.WithStack(&herodot.ErrorNotFound)
} else if err != nil {
return nil, errors.WithStack(err)
}
Expand All @@ -185,7 +185,7 @@ func (m *SQLManager) FindRolesByMember(member string, limit, offset int) ([]Role
func (m *SQLManager) ListRoles(limit, offset int) ([]Role, error) {
var ids []string
if err := m.DB.Select(&ids, m.DB.Rebind(fmt.Sprintf("SELECT id from %s LIMIT ? OFFSET ?", m.TableRole)), limit, offset); err == sql.ErrNoRows {
return nil, errors.WithStack(pkg.ErrNotFound)
return nil, errors.WithStack(&herodot.ErrorNotFound)
} else if err != nil {
return nil, errors.WithStack(err)
}
Expand Down

0 comments on commit d487344

Please sign in to comment.