Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5011662
add app-env.json and update port
shurwit Jul 1, 2022
2d9a21e
Merge pull request #1 from rokwire/develop
shurwit Oct 18, 2022
95a9dcc
Update app-env.json
shurwit Oct 18, 2022
6c7a0fe
Update app-env.json
shurwit Oct 19, 2022
a11f0e8
update detect-secrets, update secrets baseline
shurwit Nov 21, 2022
1d2508d
Merge branch 'develop' of github.com:rokwire/core-building-block into…
shurwit Nov 21, 2022
7d057ef
Merge branch 'rokwire-develop' into develop
shurwit Nov 21, 2022
39bdf91
update secrets baseline
shurwit Nov 21, 2022
ed5b051
Merge pull request #2 from rokmetro/develop
shurwit Nov 21, 2022
6fb9742
Merge branch 'develop' of github.com:rokwire/core-building-block into…
shurwit Feb 14, 2023
c72fd75
Merge branch 'rokwire-develop' into develop
shurwit Feb 14, 2023
5de2456
Merge branch 'rokwire:develop' into develop
shurwit Feb 28, 2023
1c2fec8
update makefile versioning
shurwit Feb 28, 2023
6e5e584
Merge branch 'develop' of https://github.com/rokmetro/core-building-b…
shurwit Feb 28, 2023
73d1b16
Update Makefile
shurwit Mar 1, 2023
2ea332a
print version
shurwit Mar 3, 2023
65d9a09
upgrade go to v1.20
shurwit Mar 3, 2023
fd50583
Merge remote-tracking branch 'rokwire/develop' into develop
shurwit Apr 15, 2023
c0f0e6c
fix secrets
shurwit Apr 17, 2023
8b7065a
Merge branch 'main' into develop
shurwit Apr 17, 2023
88e9f27
initial webauthn implementation (in progress)
shurwit Apr 28, 2023
7b82b03
Merge remote-tracking branch 'origin/develop' into 659-webauthn-authe…
shurwit May 4, 2023
d8d3355
refactor webauthn to handle credentials, update docs
shurwit May 5, 2023
325739d
avoid creating inaccessible accounts
shurwit May 9, 2023
7decc84
fix webauthn registration issues, add webauthn test page
shurwit May 10, 2023
e20aac5
fix webauthn login flow
shurwit May 11, 2023
eb358f7
update changelog
shurwit May 11, 2023
85929cc
Merge remote-tracking branch 'rokwire/develop' into develop
shurwit May 11, 2023
9826b5e
[#659] WebAuthn authentication (#7)
shurwit May 11, 2023
96da8ab
fix error handling
shurwit May 17, 2023
b1582d4
fix login issues for mobile
shurwit Jun 6, 2023
c126637
upgrade dependencies
shurwit Jun 9, 2023
73fe777
Merge branch 'develop' into 659-webauthn-authentication
shurwit Jun 9, 2023
e6b1597
[#659] webauthn authentication (#8)
shurwit Jun 9, 2023
233ea82
add webauthn to account check types
roberlander2 Jun 14, 2023
34c937f
Merge branch 'develop' into 659-webauthn-authentication
roberlander2 Jun 14, 2023
f698e2b
add configs for authenticator selection to supported auth type params
shurwit Jun 17, 2023
d1f5e75
merged changes from develop
roberlander2 Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_baseline_file",
"filename": ".secrets.baseline"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
Expand Down Expand Up @@ -161,7 +165,7 @@
"filename": "core/auth/auth.go",
"hashed_secret": "58f3388441fbce0e48aef2bf74413a6f43f6dc70",
"is_verified": false,
"line_number": 936
"line_number": 937
},
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -335,7 +339,7 @@
"filename": "driver/web/docs/gen/gen_types.go",
"hashed_secret": "c9739eab2dfa093cc0e450bf0ea81a43ae67b581",
"is_verified": false,
"line_number": 1797
"line_number": 1812
}
],
"driver/web/docs/resources/admin/auth/login.yaml": [
Expand Down Expand Up @@ -366,5 +370,5 @@
}
]
},
"generated_at": "2023-07-11T15:43:42Z"
"generated_at": "2023-09-11T20:21:53Z"
}
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added
- WebAuthn authentication [#659](https://github.com/rokwire/core-building-block/issues/659)
- Searching follows looks for substring matches [#670](https://github.com/rokwire/core-building-block/issues/670)

### Added
- Support following accounts [#667](https://github.com/rokwire/core-building-block/issues/667)
- Device ID not nullable [#672](https://github.com/rokwire/core-building-block/issues/672)

Expand Down
46 changes: 23 additions & 23 deletions core/auth/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (a *Auth) Login(ipAddress string, deviceType string, deviceOS *string, devi

//validate if the provided auth type is supported by the provided application and organization
authType, appType, appOrg, err := a.validateAuthType(authenticationType, appTypeIdentifier, orgID)
if err != nil {
if err != nil || authType == nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionValidate, model.TypeAuthType, nil, err)
}

Expand Down Expand Up @@ -109,12 +109,12 @@ func (a *Auth) Login(ipAddress string, deviceType string, deviceOS *string, devi
var state string

//get the auth type implementation for the auth type
if authType.IsAnonymous && !admin {
if authType.AuthType.IsAnonymous && !admin {
anonymous = true

anonymousID := ""
var account *model.Account
anonymousID, account, responseParams, err = a.applyAnonymousAuthType(*authType, creds)
anonymousID, account, responseParams, err = a.applyAnonymousAuthType(authType.AuthType, creds)
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionApply, typeAnonymousAuthType, logutils.StringArgs("user"), err)
}
Expand All @@ -123,7 +123,7 @@ func (a *Auth) Login(ipAddress string, deviceType string, deviceOS *string, devi
if account != nil {
accountAuthType = &model.AccountAuthType{Account: *account}
}
} else if authType.IsExternal {
} else if authType.AuthType.IsExternal {
accountAuthType, responseParams, mfaTypes, externalIDs, err = a.applyExternalAuthType(*authType, *appType, *appOrg, creds, params, clientVersion, profile, privacy, preferences, username, admin, l)
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionApply, typeExternalAuthType, logutils.StringArgs("user"), err)
Expand All @@ -147,7 +147,7 @@ func (a *Auth) Login(ipAddress string, deviceType string, deviceOS *string, devi
}

//check if account is enrolled in MFA
if !authType.IgnoreMFA && len(mfaTypes) > 0 {
if !authType.AuthType.IgnoreMFA && len(mfaTypes) > 0 {
state, err = utils.GenerateRandomString(loginStateLength)
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionGenerate, "login state", nil, err)
Expand All @@ -161,7 +161,7 @@ func (a *Auth) Login(ipAddress string, deviceType string, deviceOS *string, devi
}

//now we are ready to apply login for the user or anonymous
loginSession, err := a.applyLogin(anonymous, sub, *authType, *appOrg, accountAuthType, *appType, externalIDs, ipAddress, deviceType, deviceOS, deviceID, clientVersion, responseParams, state, l)
loginSession, err := a.applyLogin(anonymous, sub, authType.AuthType, *appOrg, accountAuthType, *appType, externalIDs, ipAddress, deviceType, deviceOS, deviceID, clientVersion, responseParams, state, l)
if err != nil {
return nil, nil, nil, errors.WrapErrorAction(logutils.ActionApply, "login", logutils.StringArgs("user"), err)
}
Expand Down Expand Up @@ -443,13 +443,13 @@ func (a *Auth) GetLoginURL(authenticationType string, appTypeIdentifier string,
}

//get the auth type implementation for the auth type
authImpl, err := a.getExternalAuthTypeImpl(*authType)
authImpl, err := a.getExternalAuthTypeImpl(authType.AuthType)
if err != nil {
return "", nil, errors.WrapErrorAction(logutils.ActionLoadCache, model.TypeAuthType, nil, err)
}

//get login URL
loginURL, params, err := authImpl.getLoginURL(*authType, *appType, redirectURI, l)
loginURL, params, err := authImpl.getLoginURL(authType.AuthType, *appType, redirectURI, l)
if err != nil {
return "", nil, errors.WrapErrorAction(logutils.ActionGet, "login url", nil, err)
}
Expand Down Expand Up @@ -928,7 +928,7 @@ func (a *Auth) UpdateCredential(accountID string, accountAuthTypeID string, para

credential := accountAuthType.Credential
//Determine the auth type for resetPassword
authType := accountAuthType.AuthType
authType := accountAuthType.SupportedAuthType.AuthType
if !authType.UseCredentials {
return errors.ErrorData(logutils.StatusInvalid, model.TypeAuthType, logutils.StringArgs("reset password"))
}
Expand Down Expand Up @@ -1008,7 +1008,7 @@ func (a *Auth) ResetForgotCredential(credsID string, resetCode string, params st
func (a *Auth) ForgotCredential(authenticationType string, appTypeIdentifier string, orgID string, apiKey string, identifier string, l *logs.Log) error {
//validate if the provided auth type is supported by the provided application and organization
authType, _, appOrg, err := a.validateAuthType(authenticationType, appTypeIdentifier, orgID)
if err != nil {
if err != nil || authType == nil || appOrg == nil {
return errors.WrapErrorAction(logutils.ActionValidate, model.TypeAuthType, nil, err)
}

Expand All @@ -1025,23 +1025,23 @@ func (a *Auth) ForgotCredential(authenticationType string, appTypeIdentifier str
}

//check if the auth types uses credentials
if !authType.UseCredentials {
if !authType.AuthType.UseCredentials {
return errors.ErrorData(logutils.StatusInvalid, model.TypeAuthType, logutils.StringArgs("credential reset"))
}

authImpl, err := a.getAuthTypeImpl(*authType)
authImpl, err := a.getAuthTypeImpl(authType.AuthType)
if err != nil {
return errors.WrapErrorAction(logutils.ActionLoadCache, model.TypeAuthType, nil, err)
}
authTypeID := authType.ID
authTypeID := authType.AuthType.ID

//Find the credential for setting reset code and expiry and sending credID in reset link
account, err := a.storage.FindAccount(nil, appOrg.ID, authTypeID, identifier)
if err != nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, nil, err)
}

accountAuthType, err := a.findAccountAuthType(account, authType, identifier)
accountAuthType, err := a.findAccountAuthType(account, *authType, identifier)
if accountAuthType == nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccountAuthType, nil, err)
}
Expand All @@ -1052,7 +1052,7 @@ func (a *Auth) ForgotCredential(authenticationType string, appTypeIdentifier str
a.setLogContext(account, l)

//do not allow to reset credential for unverified credentials
err = a.checkCredentialVerified(authImpl, accountAuthType, l)
err = a.checkCredentialVerified(authImpl, *accountAuthType, l)
if err != nil {
return err
}
Expand All @@ -1073,7 +1073,7 @@ func (a *Auth) ForgotCredential(authenticationType string, appTypeIdentifier str
func (a *Auth) SendVerifyCredential(authenticationType string, appTypeIdentifier string, orgID string, apiKey string, identifier string, l *logs.Log) error {
//validate if the provided auth type is supported by the provided application and organization
authType, _, appOrg, err := a.validateAuthType(authenticationType, appTypeIdentifier, orgID)
if err != nil {
if err != nil || authType == nil || appOrg == nil {
return errors.WrapErrorAction(logutils.ActionValidate, model.TypeAuthType, nil, err)
}
//validate api key before making db calls
Expand All @@ -1082,18 +1082,18 @@ func (a *Auth) SendVerifyCredential(authenticationType string, appTypeIdentifier
return errors.WrapErrorData(logutils.StatusInvalid, model.TypeAPIKey, nil, err)
}

if !authType.UseCredentials {
if !authType.AuthType.UseCredentials {
return errors.ErrorData(logutils.StatusInvalid, model.TypeAuthType, logutils.StringArgs("credential verification code"))
}
authImpl, err := a.getAuthTypeImpl(*authType)
authImpl, err := a.getAuthTypeImpl(authType.AuthType)
if err != nil {
return errors.WrapErrorAction(logutils.ActionLoadCache, model.TypeAuthType, nil, err)
}
account, err := a.storage.FindAccount(nil, appOrg.ID, authType.ID, identifier)
account, err := a.storage.FindAccount(nil, appOrg.ID, authType.AuthType.ID, identifier)
if err != nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccount, nil, err)
}
accountAuthType, err := a.findAccountAuthType(account, authType, identifier)
accountAuthType, err := a.findAccountAuthType(account, *authType, identifier)
if accountAuthType == nil {
return errors.WrapErrorAction(logutils.ActionFind, model.TypeAccountAuthType, nil, err)
}
Expand Down Expand Up @@ -1696,13 +1696,13 @@ func (a *Auth) LinkAccountAuthType(accountID string, authenticationType string,

//validate if the provided auth type is supported by the provided application and organization
authType, appType, appOrg, err := a.validateAuthType(authenticationType, appTypeIdentifier, account.AppOrg.Organization.ID)
if err != nil {
if err != nil || authType == nil || appType == nil || appOrg == nil {
return nil, nil, errors.WrapErrorAction(logutils.ActionValidate, model.TypeAuthType, nil, err)
}

if authType.IsAnonymous {
if authType.AuthType.IsAnonymous {
return nil, nil, errors.ErrorData(logutils.StatusInvalid, model.TypeAuthType, &logutils.FieldArgs{"anonymous": true})
} else if authType.IsExternal {
} else if authType.AuthType.IsExternal {
newAccountAuthType, err = a.linkAccountAuthTypeExternal(*account, *authType, *appType, *appOrg, creds, params, l)
if err != nil {
return nil, nil, errors.WrapErrorAction("linking", model.TypeCredential, nil, err)
Expand Down
Loading