Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #214 from rolsonquadras/issue-208
Browse files Browse the repository at this point in the history
feat: [gnap] integrate oidc with frontend
  • Loading branch information
rolsonquadras authored May 9, 2022
2 parents cc2ee0c + 66712fc commit 0e2bd24
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions cmd/auth-rest/startcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ func startAuthService(parameters *authRestParameters, srv server) error {
Providers: parameters.oidcParams.providers,
},
TransientStoreProvider: provider,
TLSConfig: &tls.Config{RootCAs: rootCAs}, //nolint:gosec
})
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth-vue/src/views/ProviderPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const props = defineProps({
});
onMounted(() => {
window.location.href = `/oauth2/login?provider=${props.providerID}`;
window.location.href = `/oidc/login?provider=${props.providerID}`;
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion cmd/auth-vue/src/views/SignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { t, locale } = useI18n();

onMounted(async () => {
try {
const rawProviders = await axios.get('/oauth2/providers');
const rawProviders = await axios.get('/oidc/providers');
providers.value = rawProviders.data.authProviders.sort(
(prov1, prov2) => prov1.order - prov2.order
);
Expand Down
2 changes: 1 addition & 1 deletion cmd/auth-vue/src/views/SignUp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const { t, locale } = useI18n();

onMounted(async () => {
try {
const rawProviders = await axios.get('/oauth2/providers');
const rawProviders = await axios.get('/oidc/providers');
providers.value = rawProviders.data.authProviders.sort(
(prov1, prov2) => prov1.order - prov2.order
);
Expand Down
2 changes: 2 additions & 0 deletions pkg/restapi/gnap/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Config struct {
OIDC *oidcmodel.Config
StartupTimeout uint64
TransientStoreProvider storage.Provider
TLSConfig *tls.Config
}

// New creates GNAP operation handler.
Expand Down Expand Up @@ -124,6 +125,7 @@ func New(config *Config) (*Operation, error) {
cachedOIDCProviders: make(map[string]oidcProvider),
timeout: config.StartupTimeout,
transientStore: transientStore,
tlsConfig: config.TLSConfig,
}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ hydra clients create \
--response-types code,id_token \
--scope openid,profile,email \
--skip-tls-verify \
--callbacks https://auth.trustbloc.local:8070/oauth2/callback
--callbacks https://auth.trustbloc.local:8070/oidc/callback
# TODO it would be great to check the exit status of the hydra command
# https://github.com/trustbloc/auth/issues/67
echo "Finished creating oidc client for gnap flow!"
9 changes: 4 additions & 5 deletions test/bdd/pkg/gnap/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const (
authServerURL = "https://auth.trustbloc.local:8070"
expectedInteractURL = authServerURL + "/gnap/interact"

oidcProviderSelectorURL = authServerURL + "/oauth2/login"
oidcCallbackURLURL = authServerURL + "/oauth2/callback"
oidcProviderSelectorURL = authServerURL + "/oidc/login"
oidcCallbackURLURL = authServerURL + "/oidc/callback"
authServerSignUpURL = authServerURL + "/ui/sign-up"

mockOIDCProviderName = "mockbank1" // providers.yaml
Expand Down Expand Up @@ -156,15 +156,14 @@ func (s *Steps) interactRedirect() error {
return err
}

if !strings.HasPrefix(loginResp.Request.URL.String(), oidcCallbackURLURL) {
// TODO validate the client finishURL
if !strings.HasPrefix(loginResp.Request.URL.String(), authServerURL) {
return fmt.Errorf(
"invalid oidc callbackURL prefix expected=%s actual=%s",
oidcCallbackURLURL, loginResp.Request.URL.String(),
)
}

// TODO get the redirect back

return nil
}

Expand Down

0 comments on commit 0e2bd24

Please sign in to comment.