...

Source file src/edge-infra.dev/pkg/edge/iam/barcode/compose.go

Documentation: edge-infra.dev/pkg/edge/iam/barcode

     1  package barcode
     2  
     3  import (
     4  	"github.com/ory/fosite/compose"
     5  	"github.com/ory/fosite/handler/oauth2"
     6  	"github.com/ory/fosite/handler/openid"
     7  
     8  	iamConfig "edge-infra.dev/pkg/edge/iam/config"
     9  	"edge-infra.dev/pkg/edge/iam/device"
    10  	"edge-infra.dev/pkg/edge/iam/profile"
    11  	"edge-infra.dev/pkg/edge/iam/prometheus"
    12  	"edge-infra.dev/pkg/edge/iam/session"
    13  )
    14  
    15  var (
    16  	signInBarcode      = "sign_in_barcode"
    17  	signUpBarcode      = "sign_up_barcode"
    18  	signUpBarcodeScope = "sign_up_barcode_scope"
    19  )
    20  
    21  // CodeGrantFactory builds a fosite handler for the barcode_code flow
    22  func CodeGrantFactory(_ *compose.Config, storage interface{}, _ interface{}) interface{} {
    23  	return &CodeGrantHandler{
    24  		BarcodeStrategy: &OpaqueStrategy{},
    25  		SignedStrategy: &SignedStrategy{
    26  			HMACStrategy: iamConfig.HMACStrategy(),
    27  		},
    28  		BarcodeStorage:          storage.(Storage),
    29  		BarcodeCodeHMACStrategy: iamConfig.HMACStrategy(),
    30  		Metrics:                 prometheus.NewMetrics(),
    31  	}
    32  }
    33  
    34  func ScopeFactory(_ *compose.Config, storage interface{}, _ interface{}) interface{} {
    35  	return &ScopeHandler{
    36  		BarcodeGenStrategy: &OpaqueStrategy{},
    37  		BarcodeStorage:     storage.(Storage),
    38  		Metrics:            prometheus.NewMetrics(),
    39  	}
    40  }
    41  
    42  // GrantFactory builds a fosite handler for the barcode flow
    43  func GrantFactory(config *compose.Config, storage interface{}, strategy interface{}) interface{} {
    44  	return &GrantHandler{
    45  		BarcodeStrategy:   &OpaqueStrategy{},
    46  		LoginHintStrategy: iamConfig.HMACStrategy(),
    47  		SignedStrategy: &SignedStrategy{
    48  			HMACStrategy: iamConfig.HMACStrategy(),
    49  		},
    50  		BarcodeStorage:       storage.(Storage),
    51  		AccessTokenStrategy:  strategy.(oauth2.AccessTokenStrategy),
    52  		ScopeStrategy:        config.GetScopeStrategy(),
    53  		AccessTokenStorage:   storage.(oauth2.AccessTokenStorage),
    54  		ProfileStorage:       storage.(profile.Storage),
    55  		DeviceStorage:        storage.(device.Storage),
    56  		LoginSessionStorage:  storage.(session.LoginSessionStorage),
    57  		ProfileTTL:           iamConfig.GetProfileTTL(),
    58  		BarcodeLength:        iamConfig.GetBarcodeLength(),
    59  		RefreshTokenStrategy: strategy.(oauth2.RefreshTokenStrategy),
    60  		RefreshTokenStorage:  storage.(oauth2.RefreshTokenStorage),
    61  		RefreshTokenScopes:   config.GetRefreshTokenScopes(),
    62  		RevocationStorage:    storage.(oauth2.TokenRevocationStorage),
    63  		IDTokenHandleHelper:  &openid.IDTokenHandleHelper{IDTokenStrategy: strategy.(openid.OpenIDConnectTokenStrategy)},
    64  		Metrics:              prometheus.NewMetrics(),
    65  	}
    66  }
    67  

View as plain text