generated from fluffy-bunny/fluffycore-grpc-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oidc_session.go
38 lines (33 loc) · 1010 Bytes
/
oidc_session.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
package oidc_session
import (
di "github.com/fluffy-bunny/fluffy-dozm-di"
contracts_oidc_session "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/contracts/oidc_session"
models "github.com/fluffy-bunny/fluffycore-rage-identity/pkg/models"
contracts_sessions "github.com/fluffy-bunny/fluffycore/echo/contracts/sessions"
)
type (
service struct {
factory contracts_sessions.ISessionFactory
}
)
var stemService = (*service)(nil)
func init() {
var _ contracts_oidc_session.IOIDCSession = stemService
}
func (s *service) Ctor(
factory contracts_sessions.ISessionFactory,
) (contracts_oidc_session.IOIDCSession, error) {
return &service{
factory: factory,
}, nil
}
func AddScopedIOIDCSession(cb di.ContainerBuilder) {
di.AddScoped[contracts_oidc_session.IOIDCSession](cb, stemService.Ctor)
}
func (s *service) GetSession() (contracts_sessions.ISession, error) {
session, err := s.factory.GetCookieSession(models.OIDCSessionName)
if err != nil {
return nil, err
}
return session, nil
}