Skip to content
GitLab
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
c1f78a8e
Commit
c1f78a8e
authored
Aug 03, 2018
by
Sietse Ringers
Browse files
Use hostname instead of requestor name
Co-authored-by:
Confiks
<
confiks@scriptbase.org
>
parent
b836f687
Changes
4
Hide whitespace changes
Inline
Side-by-side
irmaclient/session.go
View file @
c1f78a8e
...
...
@@ -3,6 +3,7 @@ package irmaclient
import
(
"encoding/json"
"fmt"
"net/url"
"sort"
"strings"
...
...
@@ -51,9 +52,10 @@ type SessionDismisser interface {
}
type
session
struct
{
Action
irma
.
Action
Handler
Handler
Version
*
irma
.
ProtocolVersion
Action
irma
.
Action
Handler
Handler
Version
*
irma
.
ProtocolVersion
ServerName
string
choice
*
irma
.
DisclosureChoice
client
*
Client
...
...
@@ -106,15 +108,15 @@ func (client *Client) NewSession(sessionrequest string, handler Handler) Session
// newManualSession starts a manual session, given a signature request in JSON and a handler to pass messages to
func
(
client
*
Client
)
newManualSession
(
sigrequest
*
irma
.
SignatureRequest
,
handler
Handler
)
SessionDismisser
{
session
:=
&
session
{
Action
:
irma
.
ActionSigning
,
// TODO hardcoded for now
Handler
:
handler
,
client
:
client
,
Version
:
irma
.
NewVersion
(
2
,
0
),
// TODO hardcoded for now
request
:
sigrequest
,
Action
:
irma
.
ActionSigning
,
// TODO hardcoded for now
Handler
:
handler
,
client
:
client
,
Version
:
irma
.
NewVersion
(
2
,
0
),
// TODO hardcoded for now
ServerName
:
"Email request"
,
request
:
sigrequest
,
}
session
.
Handler
.
StatusUpdate
(
session
.
Action
,
irma
.
StatusManualStarted
)
sigrequest
.
RequestorName
=
"Email request"
session
.
processSessionInfo
()
return
session
}
...
...
@@ -135,12 +137,14 @@ func (client *Client) newSchemeSession(qr *irma.SchemeManagerRequest, handler Ha
// newQrSession creates and starts a new interactive IRMA session
func
(
client
*
Client
)
newQrSession
(
qr
*
irma
.
Qr
,
handler
Handler
)
SessionDismisser
{
u
,
_
:=
url
.
ParseRequestURI
(
qr
.
URL
)
// Qr validator already checked this for errors
session
:=
&
session
{
ServerURL
:
qr
.
URL
,
transport
:
irma
.
NewHTTPTransport
(
qr
.
URL
),
Action
:
irma
.
Action
(
qr
.
Type
),
Handler
:
handler
,
client
:
client
,
ServerURL
:
qr
.
URL
,
ServerName
:
u
.
Hostname
(),
transport
:
irma
.
NewHTTPTransport
(
qr
.
URL
),
Action
:
irma
.
Action
(
qr
.
Type
),
Handler
:
handler
,
client
:
client
,
}
session
.
Handler
.
StatusUpdate
(
session
.
Action
,
irma
.
StatusCommunicating
)
...
...
@@ -228,7 +232,7 @@ func (session *session) processSessionInfo() {
candidates
,
missing
:=
session
.
client
.
CheckSatisfiability
(
session
.
request
.
ToDisclose
())
if
len
(
missing
)
>
0
{
session
.
Handler
.
UnsatisfiableRequest
(
session
.
request
.
GetRequesto
rName
()
,
missing
)
session
.
Handler
.
UnsatisfiableRequest
(
session
.
Serve
rName
,
missing
)
return
}
session
.
request
.
SetCandidates
(
candidates
)
...
...
@@ -243,13 +247,13 @@ func (session *session) processSessionInfo() {
switch
session
.
Action
{
case
irma
.
ActionDisclosing
:
session
.
Handler
.
RequestVerificationPermission
(
*
session
.
request
.
(
*
irma
.
DisclosureRequest
),
session
.
request
.
GetRequesto
rName
()
,
callback
)
*
session
.
request
.
(
*
irma
.
DisclosureRequest
),
session
.
Serve
rName
,
callback
)
case
irma
.
ActionSigning
:
session
.
Handler
.
RequestSignaturePermission
(
*
session
.
request
.
(
*
irma
.
SignatureRequest
),
session
.
request
.
GetRequesto
rName
()
,
callback
)
*
session
.
request
.
(
*
irma
.
SignatureRequest
),
session
.
Serve
rName
,
callback
)
case
irma
.
ActionIssuing
:
session
.
Handler
.
RequestIssuancePermission
(
*
session
.
request
.
(
*
irma
.
IssuanceRequest
),
session
.
request
.
GetRequesto
rName
()
,
callback
)
*
session
.
request
.
(
*
irma
.
IssuanceRequest
),
session
.
Serve
rName
,
callback
)
default
:
panic
(
"Invalid session type"
)
// does not happen, session.Action has been checked earlier
}
...
...
irmaclient/session_test.go
View file @
c1f78a8e
...
...
@@ -16,6 +16,10 @@ import (
"github.com/stretchr/testify/require"
)
func
init
()
{
irma
.
ForceHttps
=
false
}
func
getDisclosureJwt
(
name
string
,
id
irma
.
AttributeTypeIdentifier
)
interface
{}
{
return
irma
.
NewServiceProviderJwt
(
name
,
&
irma
.
DisclosureRequest
{
Content
:
irma
.
AttributeDisjunctionList
([]
*
irma
.
AttributeDisjunction
{{
...
...
messages.go
View file @
c1f78a8e
...
...
@@ -17,6 +17,8 @@ import (
// Status encodes the status of an IRMA session (e.g., connected).
type
Status
string
var
ForceHttps
bool
=
true
// ProtocolVersion encodes the IRMA protocol version of an IRMA session.
type
ProtocolVersion
struct
{
Major
int
...
...
@@ -251,13 +253,17 @@ func ParseRequestorJwt(action Action, jwt string) (RequestorJwt, error) {
return
retval
,
nil
}
func
(
qr
*
Qr
)
Validate
()
error
{
func
(
qr
*
Qr
)
Validate
()
(
err
error
)
{
if
qr
.
URL
==
""
{
return
errors
.
New
(
"No URL specified"
)
}
if
_
,
err
:=
url
.
ParseRequestURI
(
qr
.
URL
);
err
!=
nil
{
var
u
*
url
.
URL
if
u
,
err
=
url
.
ParseRequestURI
(
qr
.
URL
);
err
!=
nil
{
return
errors
.
Errorf
(
"Invalid URL: %s"
,
err
.
Error
())
}
if
ForceHttps
&&
u
.
Scheme
!=
"https"
{
return
errors
.
Errorf
(
"URL did not begin with https"
)
}
switch
qr
.
Type
{
case
ActionDisclosing
:
// nop
...
...
requests.go
View file @
c1f78a8e
...
...
@@ -17,10 +17,9 @@ import (
// BaseRequest contains the context and nonce for an IRMA session.
type
BaseRequest
struct
{
Context
*
big
.
Int
`json:"context"`
Nonce
*
big
.
Int
`json:"nonce"`
RequestorName
string
`json:"requestorName"`
Type
Action
`json:"type"`
Context
*
big
.
Int
`json:"context"`
Nonce
*
big
.
Int
`json:"nonce"`
Type
Action
`json:"type"`
Candidates
[][]
*
AttributeIdentifier
`json:"-"`
Choice
*
DisclosureChoice
`json:"-"`
...
...
@@ -53,14 +52,6 @@ func (sr *BaseRequest) GetVersion() *ProtocolVersion {
return
sr
.
Version
}
func
(
sr
*
BaseRequest
)
GetRequestorName
()
string
{
return
sr
.
RequestorName
}
func
(
sr
*
BaseRequest
)
SetRequestorName
(
name
string
)
{
sr
.
RequestorName
=
name
}
// A DisclosureRequest is a request to disclose certain attributes.
type
DisclosureRequest
struct
{
BaseRequest
...
...
@@ -145,8 +136,6 @@ type SessionRequest interface {
SetContext
(
*
big
.
Int
)
GetVersion
()
*
ProtocolVersion
SetVersion
(
*
ProtocolVersion
)
GetRequestorName
()
string
SetRequestorName
(
string
)
ToDisclose
()
AttributeDisjunctionList
DisclosureChoice
()
*
DisclosureChoice
SetDisclosureChoice
(
choice
*
DisclosureChoice
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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