mirror of
https://github.com/smallstep/certificates.git
synced 2024-10-31 03:20:16 +00:00
40 lines
777 B
Go
40 lines
777 B
Go
|
package authority
|
||
|
|
||
|
import "go.step.sm/linkedca"
|
||
|
|
||
|
func (a *Authority) Export() (*linkedca.Configuration, error) {
|
||
|
var admins []*linkedca.Admin
|
||
|
var provisioners []*linkedca.Provisioner
|
||
|
|
||
|
for {
|
||
|
list, cursor := a.admins.Find("", 100)
|
||
|
admins = append(admins, list...)
|
||
|
if cursor == "" {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for {
|
||
|
list, cursor := a.provisioners.Find("", 100)
|
||
|
for _, p := range list {
|
||
|
lp, err := ProvisionerToLinkedca(p)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
provisioners = append(provisioners, lp)
|
||
|
}
|
||
|
if cursor == "" {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Global claims for all provisioners.
|
||
|
claims := claimsToLinkedca(a.config.AuthorityConfig.Claims)
|
||
|
|
||
|
return &linkedca.Configuration{
|
||
|
Admins: admins,
|
||
|
Provisioners: provisioners,
|
||
|
Claims: claims,
|
||
|
}, nil
|
||
|
}
|