Exemplo n.º 1
0
func (m *HTTPManager) GetClients() (map[string]*fosite.DefaultClient, error) {
	cs := make(map[string]*fosite.DefaultClient)
	var r = pkg.NewSuperAgent(m.Endpoint.String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&cs); err != nil {
		return nil, err
	}

	return cs, nil
}
Exemplo n.º 2
0
func (m *HTTPManager) GetKeySet(set string) (*jose.JsonWebKeySet, error) {
	var c jose.JsonWebKeySet
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, set).String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&c); err != nil {
		return nil, err
	}

	return &c, nil
}
Exemplo n.º 3
0
func (m *HTTPManager) GetClient(id string) (fosite.Client, error) {
	var c fosite.DefaultClient
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, id).String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&c); err != nil {
		return nil, err
	}

	return &c, nil
}
Exemplo n.º 4
0
func (m *HTTPManager) Get(id string) (*Connection, error) {
	var connection Connection
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, id).String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&connection); err != nil {
		return nil, err
	}

	return &connection, nil
}
Exemplo n.º 5
0
// Get retrieves a policy.
func (m *HTTPManager) Get(id string) (ladon.Policy, error) {
	var policy = ladon.DefaultPolicy{
		Conditions: ladon.Conditions{},
	}
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, id).String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&policy); err != nil {
		return nil, err
	}

	return &policy, nil

}
Exemplo n.º 6
0
// Finds all policies associated with the subject.
func (m *HTTPManager) FindPoliciesForSubject(subject string) (ladon.Policies, error) {
	var policies []*ladon.DefaultPolicy
	var r = pkg.NewSuperAgent(m.Endpoint.String() + "?subject=" + subject)
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&policies); err != nil {
		return nil, err
	}

	ret := make(ladon.Policies, len(policies))
	for k, p := range policies {
		ret[k] = ladon.Policy(p)
	}
	return ret, nil
}
Exemplo n.º 7
0
func (m *HTTPManager) FindByRemoteSubject(provider, subject string) (*Connection, error) {
	var connection Connection
	var u = pkg.CopyURL(m.Endpoint)
	var q = u.Query()
	q.Add("remote_subject", subject)
	q.Add("provider", provider)
	u.RawQuery = q.Encode()

	var r = pkg.NewSuperAgent(u.String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&connection); err != nil {
		return nil, err
	}

	return &connection, nil
}
Exemplo n.º 8
0
func (m *HTTPManager) FindAllByLocalSubject(subject string) ([]*Connection, error) {
	var connection []*Connection
	var u = pkg.CopyURL(m.Endpoint)
	var q = u.Query()

	q.Add("local_subject", subject)
	u.RawQuery = q.Encode()

	var r = pkg.NewSuperAgent(u.String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Get(&connection); err != nil {
		return nil, err
	}

	return connection, nil
}
Exemplo n.º 9
0
func (m *HTTPManager) CreateKeys(set, algorithm string) (*jose.JsonWebKeySet, error) {
	var c = struct {
		Algorithm string            `json:"alg"`
		Keys      []jose.JsonWebKey `json:"keys"`
	}{
		Algorithm: algorithm,
	}

	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, set).String())
	r.Client = m.Client
	r.Dry = m.Dry
	if err := r.Create(&c); err != nil {
		return nil, err
	}

	return &jose.JsonWebKeySet{
		Keys: c.Keys,
	}, nil
}
Exemplo n.º 10
0
func (m *HTTPManager) DeleteKeySet(set string) error {
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, set).String())
	r.Client = m.Client
	r.Dry = m.Dry
	return r.Delete()
}
Exemplo n.º 11
0
func (m *HTTPManager) AddKeySet(set string, keys *jose.JsonWebKeySet) error {
	var r = pkg.NewSuperAgent(pkg.JoinURL(m.Endpoint, set).String())
	r.Client = m.Client
	r.Dry = m.Dry
	return r.Update(keys)
}
Exemplo n.º 12
0
func (m *HTTPManager) CreateClient(c *fosite.DefaultClient) error {
	var r = pkg.NewSuperAgent(m.Endpoint.String())
	r.Client = m.Client
	r.Dry = m.Dry
	return r.Create(c)
}
Exemplo n.º 13
0
func (m *HTTPManager) Create(connection *Connection) error {
	var r = pkg.NewSuperAgent(m.Endpoint.String())
	r.Client = m.Client
	r.Dry = m.Dry
	return r.Create(connection)
}
Exemplo n.º 14
0
// Create persists the policy.
func (m *HTTPManager) Create(policy ladon.Policy) error {
	var r = pkg.NewSuperAgent(m.Endpoint.String())
	r.Client = m.Client
	r.Dry = m.Dry
	return r.Create(policy)
}