forked from EmbeddedEnterprises/autobahnkreuz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anon.go
31 lines (27 loc) · 806 Bytes
/
anon.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
package auth
import (
"github.com/gammazero/nexus/wamp"
)
// AnonymousAuth is a authenticator which provides a configurable authrole
// for previously unauthenticated clients.
type AnonymousAuth struct {
AuthRole string
}
// Authenticate assigns an authrole and an authid to the given session.
func (a AnonymousAuth) Authenticate(_ wamp.ID, _ wamp.Dict, _ wamp.Peer) (*wamp.Welcome, error) {
return &wamp.Welcome{
Details: wamp.Dict{
"authid": string(wamp.GlobalID()),
"authrole": wamp.List{
a.AuthRole,
},
"authprovider": "static",
"authmethod": a.AuthMethod(),
},
}, nil
}
// AuthMethod returns a string representing the type of the authenticator
// Use the crossbar.io "anonymous" authmethod name here.
func (a AnonymousAuth) AuthMethod() string {
return "anonymous"
}