Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Vault
Commits
3dee1783
Commit
3dee1783
authored
9 years ago
by
Jeff Mitchell
Browse files
Options
Download
Email Patches
Plain Diff
Start rejigging JWT
parent
b2da14c3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
builtin/logical/jwt/backend.go
+0
-1
builtin/logical/jwt/backend.go
builtin/logical/jwt/backend_test.go
+18
-22
builtin/logical/jwt/backend_test.go
builtin/logical/jwt/path_issue.go
+3
-6
builtin/logical/jwt/path_issue.go
with
21 additions
and
29 deletions
+21
-29
builtin/logical/jwt/backend.go
+
0
-
1
View file @
3dee1783
...
...
@@ -19,7 +19,6 @@ func Backend() *framework.Backend {
pathRoles
(
&
b
),
pathIssue
(
&
b
),
},
}
return
b
.
Backend
...
...
This diff is collapsed.
Click to expand it.
builtin/logical/jwt/backend_test.go
+
18
-
22
View file @
3dee1783
...
...
@@ -86,7 +86,6 @@ func testAccStepReadRole(t *testing.T, name string, algorithm string, key string
return
fmt
.
Errorf
(
"missing response"
)
}
var
d
struct
{
Name
string
`json:"name" mapstructure:"name"`
Algorithm
string
`json:"algorithm" structs:"algorithm" mapstructure:"algorithm"`
Key
string
`json:"key" structs:"key" mapstructure:"key"`
Issuer
string
`json:"iss" structs:"iss" mapstructure:"iss"`
...
...
@@ -97,14 +96,11 @@ func testAccStepReadRole(t *testing.T, name string, algorithm string, key string
return
err
}
if
d
.
Name
!=
name
{
return
fmt
.
Errorf
(
"bad: %#v"
,
d
)
}
if
d
.
Algorithm
!=
algorithm
{
return
fmt
.
Errorf
(
"bad
: %#v"
,
d
)
return
fmt
.
Errorf
(
"bad
algorithm: expected %s, got %#v"
,
algorithm
,
d
)
}
if
d
.
Key
!=
key
{
return
fmt
.
Errorf
(
"bad
: %#v"
,
d
)
if
d
.
Key
!=
""
{
return
fmt
.
Errorf
(
"bad
key: expected %s, got %#v"
,
key
,
d
)
}
return
nil
...
...
This diff is collapsed.
Click to expand it.
builtin/logical/jwt/path_issue.go
+
3
-
6
View file @
3dee1783
...
...
@@ -41,8 +41,8 @@ func pathIssue(b *backend) *framework.Path {
Description
:
"Defines the time before which the JWT MUST NOT be accepted for processing"
,
},
"issued_at"
:
&
framework
.
FieldSchema
{
Type
:
framework
.
Type
Int
,
Description
:
"
T
he
time the JWT was issued
"
,
Type
:
framework
.
Type
Bool
,
Description
:
"
W
he
ther to include the issued_at claim
"
,
},
"jti"
:
&
framework
.
FieldSchema
{
Type
:
framework
.
TypeString
,
...
...
@@ -90,7 +90,7 @@ func (b *backend) pathIssueWrite(
if
data
.
Get
(
"not_before"
)
==
0
{
claims
[
"nbf"
]
=
int
(
time
.
Now
()
.
Unix
())
}
if
data
.
Get
(
"issued_at"
)
==
0
{
if
data
.
Get
(
"issued_at"
)
.
(
bool
)
{
claims
[
"iat"
]
=
int
(
time
.
Now
()
.
Unix
())
}
if
data
.
Get
(
"jti"
)
==
""
{
...
...
@@ -112,9 +112,6 @@ func (b *backend) pathIssueWrite(
if
data
.
Get
(
"not_before"
)
.
(
int
)
>
0
{
claims
[
"nbf"
]
=
data
.
Get
(
"not_before"
)
.
(
int
)
}
if
data
.
Get
(
"issued_at"
)
.
(
int
)
>
0
{
claims
[
"iat"
]
=
data
.
Get
(
"issued_at"
)
.
(
int
)
}
if
data
.
Get
(
"jti"
)
!=
""
{
claims
[
"jti"
]
=
data
.
Get
(
"jti"
)
.
(
string
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help