revoke.go 1.35 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
package cmd

import (
	irma "github.com/privacybydesign/irmago"
	"github.com/spf13/cobra"
)

var revokeCmd = &cobra.Command{
	Use:   "revoke CREDENTIALTYPE KEY [PATH]",
	Short: "Revoke a previously issued credential identified by a given key",
	Args:  cobra.RangeArgs(2, 3),
	Run: func(cmd *cobra.Command, args []string) {
13
14
15
16
17
		irmaconf := irma.DefaultSchemesPath()
		if len(args) == 3 {
			irmaconf = args[2]
		} else if irmaconf == "" {
			die("Failed to find default irma_configuration path", nil)
18
19
		}

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
		conf, err := irma.NewConfigurationReadOnly(irmaconf)
		if err != nil {
			die("", err)
		}
		if err = conf.ParseFolder(); err != nil {
			die("", err)
		}
		cred := irma.NewCredentialTypeIdentifier(args[0])
		if _, known := conf.CredentialTypes[cred]; !known {
			die("unknown credential type", nil)
		}

		flags := cmd.Flags()
		authmethod, _ := flags.GetString("authmethod")
		key, _ := flags.GetString("key")
		name, _ := flags.GetString("name")

		_ = &irma.RevocationRequest{
			LDContext:      irma.LDContextRevocationRequest,
			CredentialType: cred,
			Key:            args[1],
41
42
43
44
45
		}
	},
}

func init() {
46
47
48
49
50
	flags := revocationCmd.Flags()
	flags.StringP("authmethod", "a", "none", "Authentication method to server (none, token, rsa, hmac)")
	flags.String("key", "", "Key to sign request with")
	flags.String("name", "", "Requestor name")

51
52
	revocationCmd.AddCommand(revokeCmd)
}