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
e7954d65
Commit
e7954d65
authored
Aug 24, 2019
by
Sietse Ringers
Browse files
refactor: rename session Authenticate function to AuthenticateSession
parent
a121c1b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
server/requestorserver/auth.go
View file @
e7954d65
...
...
@@ -20,12 +20,12 @@ type Authenticator interface {
// Used to parse keys or populate caches for later use.
Initialize
(
name
string
,
requestor
Requestor
)
error
// Authenticate checks, given the HTTP header and POST body, if the authenticator is known
// Authenticate
Session
checks, given the HTTP header and POST body, if the authenticator is known
// and allowed to submit session requests. It returns whether or not the current authenticator
// is applicable to this sesion requests; the request itself; the name of the requestor;
// or an error (which is only non-nil if applies is true; i.e. this authenticator applies but
// it was not able to successfully authenticate the request).
Authenticate
(
Authenticate
Session
(
headers
http
.
Header
,
body
[]
byte
,
)
(
applies
bool
,
request
irma
.
RequestorRequest
,
requestor
string
,
err
*
irma
.
RemoteError
)
...
...
@@ -59,7 +59,7 @@ type NilAuthenticator struct{}
var
authenticators
map
[
AuthenticationMethod
]
Authenticator
func
(
NilAuthenticator
)
Authenticate
(
func
(
NilAuthenticator
)
Authenticate
Session
(
headers
http
.
Header
,
body
[]
byte
,
)
(
bool
,
irma
.
RequestorRequest
,
string
,
*
irma
.
RemoteError
)
{
if
headers
.
Get
(
"Authorization"
)
!=
""
||
!
strings
.
HasPrefix
(
headers
.
Get
(
"Content-Type"
),
"application/json"
)
{
...
...
@@ -87,7 +87,7 @@ func (NilAuthenticator) Initialize(name string, requestor Requestor) error {
return
nil
}
func
(
hauth
*
HmacAuthenticator
)
Authenticate
(
func
(
hauth
*
HmacAuthenticator
)
Authenticate
Session
(
headers
http
.
Header
,
body
[]
byte
,
)
(
applies
bool
,
request
irma
.
RequestorRequest
,
requestor
string
,
err
*
irma
.
RemoteError
)
{
return
jwtAuthenticate
(
headers
,
body
,
jwt
.
SigningMethodHS256
.
Name
,
hauth
.
hmackeys
,
hauth
.
maxRequestAge
)
...
...
@@ -114,7 +114,7 @@ func (hauth *HmacAuthenticator) Initialize(name string, requestor Requestor) err
}
func
(
pkauth
*
PublicKeyAuthenticator
)
Authenticate
(
func
(
pkauth
*
PublicKeyAuthenticator
)
Authenticate
Session
(
headers
http
.
Header
,
body
[]
byte
,
)
(
bool
,
irma
.
RequestorRequest
,
string
,
*
irma
.
RemoteError
)
{
return
jwtAuthenticate
(
headers
,
body
,
jwt
.
SigningMethodRS256
.
Name
,
pkauth
.
publickeys
,
pkauth
.
maxRequestAge
)
...
...
@@ -139,7 +139,7 @@ func (pkauth *PublicKeyAuthenticator) Initialize(name string, requestor Requesto
return
nil
}
func
(
pskauth
*
PresharedKeyAuthenticator
)
Authenticate
(
func
(
pskauth
*
PresharedKeyAuthenticator
)
Authenticate
Session
(
headers
http
.
Header
,
body
[]
byte
,
)
(
bool
,
irma
.
RequestorRequest
,
string
,
*
irma
.
RemoteError
)
{
auth
:=
headers
.
Get
(
"Authorization"
)
...
...
server/requestorserver/server.go
View file @
e7954d65
...
...
@@ -301,7 +301,7 @@ func (s *Server) handleCreate(w http.ResponseWriter, r *http.Request) {
applies
bool
)
for
_
,
authenticator
:=
range
authenticators
{
// rrequest abbreviates "requestor request"
applies
,
rrequest
,
requestor
,
rerr
=
authenticator
.
Authenticate
(
r
.
Header
,
body
)
applies
,
rrequest
,
requestor
,
rerr
=
authenticator
.
Authenticate
Session
(
r
.
Header
,
body
)
if
applies
||
rerr
!=
nil
{
break
}
...
...
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