Esempio 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
}
Esempio 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
}
Esempio 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
}
Esempio 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
}
Esempio 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

}
Esempio 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
}
Esempio 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
}
Esempio 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
}
Esempio 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
}
Esempio 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()
}
Esempio 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)
}
Esempio 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)
}
Esempio 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)
}
Esempio 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)
}