mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 00:28:44 +05:00
Added STIR authorization
This commit is contained in:
committed by
Dan Christian Bogos
parent
4994b3c3bc
commit
465b0279cd
@@ -669,6 +669,7 @@ const (
|
||||
MetaRelease = "*release"
|
||||
MetaAllocate = "*allocate"
|
||||
MetaAuthorize = "*authorize"
|
||||
MetaSTIRAuthorize = "*stir_authorize"
|
||||
MetaInit = "*init"
|
||||
MetaRatingPlanCost = "*rating_plan_cost"
|
||||
RatingPlanIDs = "RatingPlanIDs"
|
||||
@@ -1765,27 +1766,29 @@ const (
|
||||
|
||||
// SessionSCfg
|
||||
const (
|
||||
ListenBijsonCfg = "listen_bijson"
|
||||
RALsConnsCfg = "rals_conns"
|
||||
ResSConnsCfg = "resources_conns"
|
||||
ThreshSConnsCfg = "thresholds_conns"
|
||||
SupplSConnsCfg = "suppliers_conns"
|
||||
AttrSConnsCfg = "attributes_conns"
|
||||
ReplicationConnsCfg = "replication_conns"
|
||||
DebitIntervalCfg = "debit_interval"
|
||||
StoreSCostsCfg = "store_session_costs"
|
||||
MinCallDurationCfg = "min_call_duration"
|
||||
MaxCallDurationCfg = "max_call_duration"
|
||||
SessionTTLCfg = "session_ttl"
|
||||
SessionTTLMaxDelayCfg = "session_ttl_max_delay"
|
||||
SessionTTLLastUsedCfg = "session_ttl_last_used"
|
||||
SessionTTLUsageCfg = "session_ttl_usage"
|
||||
SessionIndexesCfg = "session_indexes"
|
||||
ClientProtocolCfg = "client_protocol"
|
||||
ChannelSyncIntervalCfg = "channel_sync_interval"
|
||||
TerminateAttemptsCfg = "terminate_attempts"
|
||||
AlterableFieldsCfg = "alterable_fields"
|
||||
MinDurLowBalanceCfg = "min_dur_low_balance"
|
||||
ListenBijsonCfg = "listen_bijson"
|
||||
RALsConnsCfg = "rals_conns"
|
||||
ResSConnsCfg = "resources_conns"
|
||||
ThreshSConnsCfg = "thresholds_conns"
|
||||
SupplSConnsCfg = "suppliers_conns"
|
||||
AttrSConnsCfg = "attributes_conns"
|
||||
ReplicationConnsCfg = "replication_conns"
|
||||
DebitIntervalCfg = "debit_interval"
|
||||
StoreSCostsCfg = "store_session_costs"
|
||||
MinCallDurationCfg = "min_call_duration"
|
||||
MaxCallDurationCfg = "max_call_duration"
|
||||
SessionTTLCfg = "session_ttl"
|
||||
SessionTTLMaxDelayCfg = "session_ttl_max_delay"
|
||||
SessionTTLLastUsedCfg = "session_ttl_last_used"
|
||||
SessionTTLUsageCfg = "session_ttl_usage"
|
||||
SessionIndexesCfg = "session_indexes"
|
||||
ClientProtocolCfg = "client_protocol"
|
||||
ChannelSyncIntervalCfg = "channel_sync_interval"
|
||||
TerminateAttemptsCfg = "terminate_attempts"
|
||||
AlterableFieldsCfg = "alterable_fields"
|
||||
MinDurLowBalanceCfg = "min_dur_low_balance"
|
||||
STIRAtestCfg = "stir_attest"
|
||||
STIRPayloadMaxdurationCfg = "stir_payload_maxduration"
|
||||
)
|
||||
|
||||
// FsAgentCfg
|
||||
@@ -1965,6 +1968,28 @@ const (
|
||||
CacheDumpFieldsCfg = "cache_dump_fields"
|
||||
)
|
||||
|
||||
// STIR/SHAKEN
|
||||
const (
|
||||
STIRAlg = "ES256"
|
||||
STIRPpt = "shaken"
|
||||
STIRTyp = "passport"
|
||||
|
||||
STIRAlgField = "alg"
|
||||
STIRPptField = "ppt"
|
||||
STIRInfoField = "info"
|
||||
|
||||
STIRATest = "STIRATest"
|
||||
STIRPayloadMaxDuration = "STIRPayloadMaxDuration"
|
||||
STIRIdentity = "STIRIdentity"
|
||||
STIROriginatorTn = "STIROriginatorTn"
|
||||
STIROriginatorURI = "STIROriginatorURI"
|
||||
STIRDestinationTn = "STIRDestinationTn"
|
||||
STIRDestinationURI = "STIRDestinationURI"
|
||||
|
||||
STIRExtraInfoPrefix = ";info=<"
|
||||
STIRExtraInfoSuffix = ">;alg=ES256;ppt=shaken"
|
||||
)
|
||||
|
||||
// Strip/Padding strategy
|
||||
var (
|
||||
// common
|
||||
|
||||
@@ -475,10 +475,7 @@ func Clone(a, b interface{}) error {
|
||||
if err := enc.Encode(a); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := dec.Decode(b); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return dec.Decode(b)
|
||||
}
|
||||
|
||||
// Used as generic function logic for various fields
|
||||
|
||||
@@ -261,3 +261,8 @@ func ErrPathNotReachable(path string) error {
|
||||
func ErrNotConvertibleTF(from, to string) error {
|
||||
return fmt.Errorf("%s : from: %s to:%s", ErrNotConvertibleNoCaps.Error(), from, to)
|
||||
}
|
||||
|
||||
// NewSTIRError returns a error with a *stir_authorize prefix
|
||||
func NewSTIRError(reason string) error {
|
||||
return fmt.Errorf("<%s> %s", MetaSTIRAuthorize, reason)
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ import (
|
||||
// extension shaken, ES256 algorithm and the given x5u
|
||||
func NewPASSporTHeader(x5uVal string) *PASSporTHeader {
|
||||
return &PASSporTHeader{
|
||||
Alg: "ES256",
|
||||
Ppt: "shaken",
|
||||
Typ: "passport",
|
||||
Alg: STIRAlg,
|
||||
Ppt: STIRPpt,
|
||||
Typ: STIRTyp,
|
||||
X5u: x5uVal,
|
||||
}
|
||||
}
|
||||
@@ -88,5 +88,3 @@ type PASSporTPayload struct {
|
||||
Orig PASSporTOriginsIdentity `json:"orig"` // the originator identity
|
||||
OrigID string `json:"origid"` // is an opaque unique identifier representing an element on the path of a given SIP request. Not used for verification
|
||||
}
|
||||
|
||||
// atestare cu set cu `,` si support pt `*any`
|
||||
|
||||
@@ -94,8 +94,7 @@ func DecodeBase64JSON(data string, val interface{}) (err error) {
|
||||
if b, err = jwt.DecodeSegment(data); err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(b, val)
|
||||
return
|
||||
return json.Unmarshal(b, val)
|
||||
}
|
||||
|
||||
func RemoveWhiteSpaces(str string) string {
|
||||
|
||||
Reference in New Issue
Block a user