Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
00988615
Commit
00988615
authored
Aug 29, 2018
by
Sietse Ringers
Browse files
Add Action field to jwts and make them implement jwt.Claims
parent
f634e01e
Changes
2
Hide whitespace changes
Inline
Side-by-side
messages.go
View file @
00988615
...
...
@@ -252,14 +252,14 @@ func JwtDecode(jwt string, body interface{}) error {
return
json
.
Unmarshal
(
bodybytes
,
body
)
}
func
ParseRequestorJwt
(
action
Action
,
jwt
string
)
(
RequestorJwt
,
error
)
{
func
ParseRequestorJwt
(
action
string
,
jwt
string
)
(
RequestorJwt
,
error
)
{
var
retval
RequestorJwt
switch
action
{
case
ActionDisclosing
:
case
"verification_request"
:
retval
=
&
ServiceProviderJwt
{}
case
ActionSigning
:
case
"signature_request"
:
retval
=
&
SignatureRequestorJwt
{}
case
ActionIssuing
:
case
"issue_request"
:
retval
=
&
IdentityProviderJwt
{}
default
:
return
nil
,
errors
.
New
(
"Invalid session type"
)
...
...
requests.go
View file @
00988615
...
...
@@ -487,8 +487,10 @@ func NewIdentityProviderJwt(servername string, ir *IssuanceRequest) *IdentityPro
// A RequestorJwt contains an IRMA session object.
type
RequestorJwt
interface
{
Action
()
Action
SessionRequest
()
SessionRequest
Requestor
()
string
Valid
()
error
}
func
(
jwt
*
ServerJwt
)
Requestor
()
string
{
return
jwt
.
ServerName
}
...
...
@@ -501,3 +503,39 @@ func (jwt *SignatureRequestorJwt) SessionRequest() SessionRequest { return jwt.R
// SessionRequest returns an IRMA session object.
func
(
jwt
*
IdentityProviderJwt
)
SessionRequest
()
SessionRequest
{
return
jwt
.
Request
.
Request
}
func
(
jwt
*
ServiceProviderJwt
)
Valid
()
error
{
if
jwt
.
Type
!=
"verification_request"
{
return
errors
.
New
(
"Verification jwt has invalid subject"
)
}
if
time
.
Time
(
jwt
.
IssuedAt
)
.
After
(
time
.
Now
())
{
return
errors
.
New
(
"Verification jwt not yet valid"
)
}
return
nil
}
func
(
jwt
*
SignatureRequestorJwt
)
Valid
()
error
{
if
jwt
.
Type
!=
"signature_request"
{
return
errors
.
New
(
"Signature jwt has invalid subject"
)
}
if
time
.
Time
(
jwt
.
IssuedAt
)
.
After
(
time
.
Now
())
{
return
errors
.
New
(
"Signature jwt not yet valid"
)
}
return
nil
}
func
(
jwt
*
IdentityProviderJwt
)
Valid
()
error
{
if
jwt
.
Type
!=
"issue_request"
{
return
errors
.
New
(
"Issuance jwt has invalid subject"
)
}
if
time
.
Time
(
jwt
.
IssuedAt
)
.
After
(
time
.
Now
())
{
return
errors
.
New
(
"Issuance jwt not yet valid"
)
}
return
nil
}
func
(
jwt
*
ServiceProviderJwt
)
Action
()
Action
{
return
ActionDisclosing
}
func
(
jwt
*
SignatureRequestorJwt
)
Action
()
Action
{
return
ActionSigning
}
func
(
jwt
*
IdentityProviderJwt
)
Action
()
Action
{
return
ActionIssuing
}
Write
Preview
Markdown
is supported
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