forked from stretchr/gomniauth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcuts.go
32 lines (25 loc) · 882 Bytes
/
shortcuts.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
32
package gomniauth
import (
"github.com/stretchr/gomniauth/common"
"github.com/stretchr/objx"
)
// Provider gets a provider by name from the
// SharedProviderList, or returns a common.MissingProviderError
// if no provider with that name is registered.
func Provider(name string) (common.Provider, error) {
return SharedProviderList.Provider(name)
}
// NewState creates a new object that can be used to persist
// state across authentication requests.
func NewState(keyAndValuePairs ...interface{}) *common.State {
return common.NewState(keyAndValuePairs...)
}
// StateFromParam decodes the state parameter hash and turns it
// into a usable State object.
func StateFromParam(paramValue string) (*common.State, error) {
stateMap, err := objx.FromSignedBase64(paramValue, GetSecurityKey())
if err != nil {
return nil, err
}
return &common.State{Map: stateMap}, nil
}