Beispiel #1
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
}
Beispiel #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
}
Beispiel #3
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
}
Beispiel #4
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

}
Beispiel #5
0
func (c *Config) Resolve(join ...string) *url.URL {
	c.Lock()
	defer c.Unlock()

	if c.cluster == nil {
		cluster, err := url.Parse(c.ClusterURL)
		c.cluster = cluster
		pkg.Must(err, "Could not parse cluster url: %s", err)
	}

	if len(join) == 0 {
		return c.cluster
	}

	return pkg.JoinURL(c.cluster, join...)
}
Beispiel #6
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
}
Beispiel #7
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()
}
Beispiel #8
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)
}