Skip to content

Commit

Permalink
Merge develop into main (#52)
Browse files Browse the repository at this point in the history
* [ID-50] Service token is required to create RemoteAuthDataLoaderImpl (#51)

* fix service token requirement

* add missing nil check

* update changelog
  • Loading branch information
shurwit committed Apr 28, 2022
1 parent 0192e6e commit f1652b9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
37 changes: 17 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file.
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
## [Unreleased]

## [1.0.9] - 2022-04-27
## Fixed
- Service token is required to create RemoteAuthDataLoaderImpl [#50](https://github.com/rokwire/core-auth-library-go/issues/50)

## [1.0.8] - 2022-04-04
### Fixed
Expand Down Expand Up @@ -33,25 +37,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Standardize fetching certain data from a remote auth service [#20](https://github.com/rokwire/core-auth-library-go/issues/20)
- Link service accounts to service registrations [#19](https://github.com/rokwire/core-auth-library-go/issues/19)

## [1.0.6] - 2022-03-03
### Changed
- Improve signature interfaces for request body [#29](https://github.com/rokwire/core-auth-library-go/issues/29)
### Fixed
- Content length header missing when signing request [#27](https://github.com/rokwire/core-auth-library-go/issues/27)
### Added
- Provide permanent claim for external ID [#24](https://github.com/rokwire/core-auth-library-go/issues/24)
- Add session ID claim [#32](https://github.com/rokwire/core-auth-library-go/issues/32)

## [1.0.5] - 2021-12-21
### Added
- Standardize fetching certain data from a remote auth service [#20](https://github.com/rokwire/core-auth-library-go/issues/20)
- Link service accounts to service registrations [#19](https://github.com/rokwire/core-auth-library-go/issues/19)

## [1.0.5] - 2021-12-21
### Added
- Standardize fetching certain data from a remote auth service [#20](https://github.com/rokwire/core-auth-library-go/issues/20)
- Link service accounts to service registrations [#19](https://github.com/rokwire/core-auth-library-go/issues/19)

## [1.0.4] - 2021-12-03
### Added
- Write unit tests for sigauth package [#17](https://github.com/rokwire/core-auth-library-go/pull/17)
Expand All @@ -73,3 +58,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [1.0.0] - 2021-10-01
### Added
- Initial release

[Unreleased]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.9....HEAD
[1.0.9]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.8...v1.0.9
[1.0.8]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.7...v1.0.8
[1.0.7]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/rokwire/core-auth-library-go/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/rokwire/core-auth-library-go/tree/v1.0.0
29 changes: 18 additions & 11 deletions authservice/auth_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ func (a *AuthService) setServices(services []ServiceReg) {

// NewAuthService creates and configures a new AuthService instance
func NewAuthService(serviceID string, serviceHost string, dataLoader AuthDataLoader) (*AuthService, error) {
if dataLoader == nil {
return nil, errors.New("data loader is missing")
}

// Subscribe to the implementing service to validate registration
dataLoader.SubscribeService(serviceID)

Expand Down Expand Up @@ -432,9 +436,6 @@ func NewRemoteAuthDataLoader(config RemoteAuthDataLoaderConfig, subscribedServic
if config.AuthServicesHost == "" {
return nil, errors.New("auth services host is missing")
}
if config.ServiceToken == "" && config.DeletedAccountsCallback != nil {
return nil, errors.New("service token is missing")
}

err := constructDataLoaderConfig(&config)
if err != nil {
Expand Down Expand Up @@ -466,16 +467,22 @@ func constructDataLoaderConfig(config *RemoteAuthDataLoaderConfig) error {
config.ServiceRegPath = "/bbs/service-regs"
}

if config.AccessTokenRequest == nil {
r, err := authutils.GetDefaultAccessTokenRequest(config.AuthServicesHost, config.AccessTokenPath, config.ServiceToken)
if err != nil {
return err
}
requiresAccessToken := (config.DeletedAccountsCallback != nil)
if requiresAccessToken {
if config.AccessTokenRequest == nil {
r, err := authutils.GetDefaultAccessTokenRequest(config.AuthServicesHost, config.AccessTokenPath, config.ServiceToken)
if err != nil {
return err
}

config.AccessTokenRequest = r
config.AccessTokenRequest = r
}
}
if config.GetDeletedAccountsPeriod <= 0 {
config.GetDeletedAccountsPeriod = 2

if config.DeletedAccountsCallback != nil {
if config.GetDeletedAccountsPeriod <= 0 {
config.GetDeletedAccountsPeriod = 2
}
}

return nil
Expand Down

0 comments on commit f1652b9

Please sign in to comment.