-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput_introspection.go
56 lines (43 loc) · 1.04 KB
/
output_introspection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright © 2022 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package cmd
import (
"fmt"
"time"
"github.com/ory/x/pointerx"
hydra "github.com/ory/hydra-client-go/v2"
)
type (
outputOAuth2TokenIntrospection hydra.IntrospectedOAuth2Token
)
func (outputOAuth2TokenIntrospection) Header() []string {
return []string{"ACTIVE", "SUBJECT", "CLIENT ID", "SCOPE", "EXPIRY", "TOKEN USE"}
}
func (i outputOAuth2TokenIntrospection) Columns() []string {
if i.Sub == nil {
i.Sub = pointerx.String("")
}
if i.ClientId == nil {
i.ClientId = pointerx.String("")
}
if i.Scope == nil {
i.Scope = pointerx.String("")
}
if i.TokenUse == nil {
i.TokenUse = pointerx.String("")
}
if i.Exp == nil {
i.Exp = pointerx.Int64(0)
}
return []string{
fmt.Sprintf("%v", i.Active),
fmt.Sprintf("%v", *i.Sub),
fmt.Sprintf("%v", *i.ClientId),
fmt.Sprintf("%v", *i.Scope),
fmt.Sprintf("%v", time.Unix(*i.Exp, 0).String()),
fmt.Sprintf("%v", *i.TokenUse),
}
}
func (i outputOAuth2TokenIntrospection) Interface() interface{} {
return i
}