/
agent.go
78 lines (62 loc) · 2.27 KB
/
agent.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// Package agent is an identity provider that uses the agent authentication scheme.
package agent
import (
"net/http"
"golang.org/x/net/context"
errgo "gopkg.in/errgo.v1"
"gopkg.in/macaroon-bakery.v2/httpbakery"
"github.com/CanonicalLtd/blues-identity/config"
"github.com/CanonicalLtd/blues-identity/idp"
"github.com/CanonicalLtd/blues-identity/store"
)
// IdentityProvider is the instance of the agent identity provider.
//
// Note: this identity provider will no longer be used, it is provided
// for backwards-compatibility purposes only. The agent functionality is
// now built in to the identity manager.
var IdentityProvider idp.IdentityProvider = (*identityProvider)(nil)
func init() {
config.RegisterIDP("agent", func(func(interface{}) error) (idp.IdentityProvider, error) {
return IdentityProvider, nil
})
}
// identityProvider allows login using pre-registered agent users.
type identityProvider struct{}
// Name gives the name of the identity provider (agent).
func (*identityProvider) Name() string {
return "agent"
}
// Domain returns "" as the agent identity provider will not create
// users.
func (*identityProvider) Domain() string {
return ""
}
// Description gives a description of the identity provider.
func (*identityProvider) Description() string {
return ""
}
// Interactive specifies that this identity provider is not interactive.
func (*identityProvider) Interactive() bool {
return false
}
// Init implements idp.IdentityProvider.Init by doing nothing.
func (*identityProvider) Init(context.Context, idp.InitParams) error {
return errgo.New("agent login IDP no longer supported")
}
// URL gets the login URL to use this identity provider.
func (*identityProvider) URL(string) string {
return ""
}
// SetInteraction implements idp.IdentityProvider.SetInteraction by doing
// nothing.
func (*identityProvider) SetInteraction(ierr *httpbakery.Error, dischargeID string) {
}
// Handle handles the agent login process.
func (*identityProvider) Handle(context.Context, http.ResponseWriter, *http.Request) {
}
// GetGroups implements idp.IdentityProvider.GetGroups.
func (*identityProvider) GetGroups(context.Context, *store.Identity) ([]string, error) {
return nil, nil
}