Class: StrategyUsingPassport
strategies/StrategyUsingPassport.StrategyUsingPassport
Hierarchy
↳
StrategyUsingPassport
Constructors
constructor
• new StrategyUsingPassport(typeName
, strategyInstanceService
, strategiesService
, passportJwtService
, canLoginRegister?
, canSync?
, needsRedirectFlow?
, allowsImplicitSignup?
)
Parameters
Name | Type | Default value |
---|---|---|
typeName | string | undefined |
strategyInstanceService | StrategyInstanceService | undefined |
strategiesService | StrategiesService | undefined |
passportJwtService | JwtService | undefined |
canLoginRegister | boolean | true |
canSync | boolean | false |
needsRedirectFlow | boolean | false |
allowsImplicitSignup | boolean | false |
Overrides
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:12
Properties
allowsImplicitSignup
• Readonly
allowsImplicitSignup: boolean
= false
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:27
canLoginRegister
• Readonly
canLoginRegister: boolean
= true
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:24
canSync
• Readonly
canSync: boolean
= false
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:25
logger
• Private
Readonly
logger: Logger
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:11
needsRedirectFlow
• Readonly
needsRedirectFlow: boolean
= false
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:26
passportInstances
• Private
Readonly
passportInstances: Map
<string
, Strategy
>
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:33
passportJwtService
• Protected
Readonly
passportJwtService: JwtService
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:16
strategiesService
• Protected
Readonly
strategiesService: StrategiesService
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:23
strategyInstanceService
• Protected
Readonly
strategyInstanceService: StrategyInstanceService
Inherited from
Strategy.strategyInstanceService
Defined in
login-service/src/strategies/Strategy.ts:22
typeName
• Readonly
typeName: string
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:21
Accessors
acceptsVariables
• get
acceptsVariables(): Object
Returns
Object
Inherited from
Strategy.acceptsVariables
Defined in
login-service/src/strategies/Strategy.ts:131
Methods
checkAndExtendInstanceConfig
▸ Protected
checkAndExtendInstanceConfig(instanceConfig
): object
Checks the given config for a instance and extends it (e.g. with default values) of this strategy for validity
For strategies that can sync, this checks the existance and format of
imsTemplatedFieldsFilter
in the instance config.
This is expected to contain the fields with the values that are expected
for an IMS to be considered an ims fot this strategy instance.
Parameters
Name | Type | Description |
---|---|---|
instanceConfig | object | The config object to check for validity |
Returns
object
The instance config in the way as it should be insterted in the instance
Throws
Any error/exception if the instance config was invalid and no instance may be crated
Inherited from
Strategy.checkAndExtendInstanceConfig
Defined in
login-service/src/strategies/Strategy.ts:45
createOrUpdateNewInstance
▸ createOrUpdateNewInstance(input
, instanceToUpdate?
): Promise
<StrategyInstance
>
Parameters
Name | Type |
---|---|
input | UpdateStrategyInstanceInput | CreateStrategyInstanceInput |
instanceToUpdate? | StrategyInstance |
Returns
Promise
<StrategyInstance
>
Inherited from
Strategy.createOrUpdateNewInstance
Defined in
login-service/src/strategies/Strategy.ts:76
createPassportStrategyInstance
▸ Abstract
createPassportStrategyInstance(strategyInstance
): Strategy
Parameters
Name | Type |
---|---|
strategyInstance | StrategyInstance |
Returns
Strategy
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:35
existsInstanceClearName
▸ existsInstanceClearName(name
): Promise
<boolean
>
Parameters
Name | Type |
---|---|
name | string |
Returns
Promise
<boolean
>
Inherited from
Strategy.existsInstanceClearName
Defined in
login-service/src/strategies/Strategy.ts:116
getAdditionalPassportOptions
▸ Protected
getAdditionalPassportOptions(strategyInstance
, authStateData
): AuthenticateOptions
Parameters
Name | Type |
---|---|
strategyInstance | StrategyInstance |
authStateData | object | AuthStateData |
Returns
AuthenticateOptions
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:37
getAllInstances
▸ getAllInstances(): Promise
<StrategyInstance
[]>
Returns
Promise
<StrategyInstance
[]>
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:120
getImsTemplatedValuesForStrategyInstance
▸ getImsTemplatedValuesForStrategyInstance(instance
): object
| Promise
<object
>
Returns the object containing the templated fields and their values that an IMS needs to match, in order to be considered tha IMS that is represented by the strategy instance given. Values will be compared field by field with the templated values of the IMS.
The fields id
, name
and description
of the returned object will not be compared to the templated values,
but instead to the actual fields of the IMS with those respective names.
For example: The API-Url must match in order for a GitHub IMS belonging to a GitHub strategy instance
Can/Should be overridden by strategies capable of sync.
Default implementation returns imsTemplatedFieldsFilter
of instance config
Parameters
Name | Type | Description |
---|---|---|
instance | StrategyInstance | The strategy instance for which the templated values should be retuned |
Returns
object
| Promise
<object
>
An object which, if it matches the templated fields of an IMS, the given instance is the matching strategy instance for that IMS Null if the strategy does not sync
Inherited from
Strategy.getImsTemplatedValuesForStrategyInstance
Defined in
login-service/src/strategies/Strategy.ts:161
getImsUserTemplatedValuesForLoginData
▸ getImsUserTemplatedValuesForLoginData(loginData
): object
| Promise
<object
>
Returns the object containing the templated fields and their values that an IMSUser needs to match,
in order to be considered an IMSUser that belongs to the given loginData
(i.e. the IMS is a login of the user of this login data on the ims of this login data)
The fields id
, username
, displayName
and email
of the returned object
will not be compared to the templated values,
but instead to the actual fields of the IMSUser with those respective names.
For example: The username on GitHub must match the username in the login data.
Can/Should/Must be overridden by strategies capable of sync.
Default implementation returns the loginData.data
field unchanged
Parameters
Name | Type | Description |
---|---|---|
loginData | UserLoginData | The login data for which the templated field values should be returned, representing a login of the user using a strategy instance |
Returns
object
| Promise
<object
>
An object which, if it matches the templated fields of an IMSUser, the given loginData is the matching login for that IMSUser Null if the strategy does not sync
Inherited from
Strategy.getImsUserTemplatedValuesForLoginData
Defined in
login-service/src/strategies/Strategy.ts:188
getInstanceById
▸ getInstanceById(id
): Promise
<StrategyInstance
>
Parameters
Name | Type |
---|---|
id | string |
Returns
Promise
<StrategyInstance
>
Inherited from
Defined in
login-service/src/strategies/Strategy.ts:124
getLoginDataDataForImsUserTemplatedFields
▸ getLoginDataDataForImsUserTemplatedFields(imsUserTemplatedFields
): object
| Promise
<object
>
Does the opposite of getImsUserTemplatedValuesForLoginData
.
Returns an object that needs to match the data field of a LoginData
in order for the IMSUser to be considerd matching the login data.
The imsUserTemplatedFields
should also contain the fields
id
, username
, displayName
and email
directly of the IMSUser
in addition to the templated fields and values.
For example: Given templated fields of an IMSUser containing its username, this should return the login data object that also matches the user with that username
Can/Should/Must be overridden by strategies capable of sync.
Default implementation returns the imsUserTemplatedFields
unchanged
Parameters
Name | Type | Description |
---|---|---|
imsUserTemplatedFields | object | Templated fields and values as well as the fields id , username , displayName and email of the IMSUser. |
Returns
object
| Promise
<object
>
An object, that the .data
field of a login data needs to match.
Inherited from
Strategy.getLoginDataDataForImsUserTemplatedFields
Defined in
login-service/src/strategies/Strategy.ts:217
getPassportStrategyInstanceFor
▸ getPassportStrategyInstanceFor(strategyInstance
): Strategy
Parameters
Name | Type |
---|---|
strategyInstance | StrategyInstance |
Returns
Strategy
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:44
getSyncDataForLoginData
▸ getSyncDataForLoginData(loginData
): { [key: string]
: any
; token
: string
} | Promise
<{ [key: string]
: any
; token
: string
}>
Parameters
Name | Type |
---|---|
loginData | UserLoginData |
Returns
{ [key: string]
: any
; token
: string
} | Promise
<{ [key: string]
: any
; token
: string
}>
Inherited from
Strategy.getSyncDataForLoginData
Defined in
login-service/src/strategies/Strategy.ts:137
getUserDataSuggestion
▸ getUserDataSuggestion(loginData
): Object
For a given login data return data that has been retrieved from the authentication source with which to prefill the input fields for the user registration
WARNING: Does not check wether the returned data is valid or e.g. a username is unique. This is purely a data mapper.
Parameters
Name | Type | Description |
---|---|---|
loginData | UserLoginData | The login data of the authentication for which to retrieve the data |
Returns
Object
Suggestions for the user data based on the login data. NOT checked!
Name | Type |
---|---|
displayName? | string |
email? | string |
username? | string |
Inherited from
Strategy.getUserDataSuggestion
Defined in
login-service/src/strategies/Strategy.ts:234
performAuth
▸ performAuth(strategyInstance
, authStateData
, req
, res
): Promise
<{ info
: any
; result
: AuthResult
; returnedState
: AuthStateData
}>
Parameters
Name | Type |
---|---|
strategyInstance | StrategyInstance |
authStateData | object | AuthStateData |
req | any |
res | any |
Returns
Promise
<{ info
: any
; result
: AuthResult
; returnedState
: AuthStateData
}>
Overrides
Defined in
login-service/src/strategies/StrategyUsingPassport.ts:57
toJSON
▸ toJSON(): Object
Returns
Object
Name | Type |
---|---|
acceptsVariables | { [variableName: string] : StrategyVariable ; } |
allowsImplicitSignup | boolean |
canLoginRegister | boolean |
canSync | boolean |
needsRedirectFlow | boolean |
typeName | string |