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 }
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 }
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 }
// 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 }
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...) }
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 }
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() }
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) }