Ejemplo n.º 1
0
func newClientModel(cli client.Client) (*clientModel, error) {
	hashed, err := client.HashSecret(cli.Credentials)
	if err != nil {
		return nil, err
	}

	if cli.Public {
		// Metadata.Valid(), and therefore json.Unmarshal(metadata) complains
		// when there's no RedirectURIs, so we set them to a fixed value here,
		// and remove it when translating back to a client.Client
		cli.Metadata.RedirectURIs = []url.URL{
			localHostRedirectURL,
		}
	}

	bmeta, err := json.Marshal(&cli.Metadata)
	if err != nil {
		return nil, err
	}

	cim := clientModel{
		ID:       cli.Credentials.ID,
		Secret:   hashed,
		Metadata: string(bmeta),
		DexAdmin: cli.Admin,
		Public:   cli.Public,
	}

	return &cim, nil
}
Ejemplo n.º 2
0
func newClientModel(cli client.Client) (*clientModel, error) {
	hashed, err := client.HashSecret(cli.Credentials)
	if err != nil {
		return nil, err
	}
	bmeta, err := json.Marshal(&cli.Metadata)
	if err != nil {
		return nil, err
	}

	cim := clientModel{
		ID:       cli.Credentials.ID,
		Secret:   hashed,
		Metadata: string(bmeta),
		DexAdmin: cli.Admin,
	}

	return &cim, nil
}