Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Adds support for Webfinger API calls #70

Merged
merged 1 commit into from
Nov 1, 2017

Conversation

gowthamidommety-okta
Copy link
Contributor

Resolves: OKTA-145614

Copy link

@rajaguruduraisamy-okta rajaguruduraisamy-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Do we need to add docs for the same ?

@gowthamidommety-okta
Copy link
Contributor Author

@rajaguruduraisamy-okta Yea, i started making changes to the docs, but have some questions. Will speak to Len when he's back.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.
Do we need to add info about the new webfinger function in the README.md file? There is doc about signIn there, so might be a good idea to let people know about webfinger... unless it is in beta, but in any case, it will be in the repo, so might as well doc it.

@gowthamidommety-okta
Copy link
Contributor Author

@mauriciocastillosilva-okta It is in beta, so i was wondering about the process for updating docs and README.md.. I'm almost done updating readme. I'll go ahead and add it to this PR

Copy link

@rajaguruduraisamy-okta rajaguruduraisamy-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

README.md Outdated

- `resource` - URI that identifies the entity whose information is sought, currently only acct scheme is supported (e.g acct:dade.murphy@example.com)
- `rel` - Optional parameter to request only a subset of the information that would otherwise be returned without the "rel" parameter
- `requestContext` - A parameter that provides Webfinger the context of that which the user is trying to access, such as the path of an app

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought only rel was optional. requestContext is optional too?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is optional.

README.md Outdated
authClient.webfinger({
resource: 'acct:john.joe@example.com',
rel: 'okta:idp',
requestContext: 'https://example.okta.com'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not need to pass the requestContext if user just tries to access the homepage, an example of requestContext will be "/home/dropbox/0oa16630PzpWKeWrH0g4/121"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Will change

"und" : "Acme Partner IdP"
},
"properties": {
"okta:logo" : "https://ok3static.oktacdn.com/bc/image/fileStoreRecord?id=fs0w8swww6KGUZZWGSHS",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okta:logo has not implemented yet, does UI need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, not yet anyway. I took this example response from the Tech Design just to test

lib/http.js Outdated
@@ -5,6 +5,7 @@ var storageUtil = require('./storageUtil');
var Q = require('q');
var AuthApiError = require('./errors/AuthApiError');
var config = require('./config');
var $ = require('jquery');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this change. Only a few files have a dependency on jquery

Copy link
Contributor

@lboyette-okta lboyette-okta Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to keep auth-js small and jQuery is a pretty big dependency, so if a dev wants to use jquery, they have to do it explicitly.

For example, normally, okta-auth-js is imported like this: var oktaAuth = require('@okta/okta-auth-js'). This uses a small library called reqwest to make http requests. If a dev wants to use jQuery to makes requests instead, they can import okta-auth-js like this: var oktaAuth = require('@okta/okta-auth-js/jquery').

So, yeah, it's a good idea to avoid it when possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@lboyette-okta lboyette-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the right track, only a few questions

README.md Outdated
@@ -24,6 +24,7 @@ Read our [contributing guidelines](./CONTRIBUTING.md) if you wish to contribute.
* [forgotPassword](#forgotpasswordoptions)
* [unlockAccount](#unlockaccountoptions)
* [verifyRecoveryToken](#verifyrecoverytokenoptions)
* [webfinger](#webfinger)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't point to a heading (I think you want #webfingeroptions)

README.md Outdated
@@ -244,6 +245,28 @@ authClient.verifyRecoveryToken({
});
```

## [webfinger(options)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any docs on developer.okta.com for this api yet, so we can just provide a link to the spec for now: [webfinger(options)](https://tools.ietf.org/html/rfc7033)


```javascript
authClient.webfinger({
resource: 'acct:john.joe@example.com',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to allow a custom issuer or is webfinger only available on the root Okta url?

@@ -166,6 +166,17 @@ proto.verifyRecoveryToken = function (opts) {
return tx.postToTransaction(this, '/api/v1/authn/recovery/token', opts);
};

// { resource, (rel), (requestContext)}
proto.webfinger = function (opts) {
var url = '/.well-known/webfinger' + util.toQueryParams(opts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should figure out if a custom auth server issuer is allowed. If so, we can do something like this:

var issuer = opts.issuer || sdk.options.issuer || sdk.options.url;
var params = util.omit(opts, 'issuer');
var url = issuer + '/.well-known/webfinger' + util.toQueryParams(params);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure. @yuliu-okta Can you please comment?

Copy link
Contributor Author

@gowthamidommety-okta gowthamidommety-okta Nov 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spoke to @yuliu-okta offline. He said we may support custom auth server issuer in the future, but not now

'Accept': 'application/jrd+json'
}
};
return tx.getFromTransaction(this, url, options);
Copy link
Contributor

@lboyette-okta lboyette-okta Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a transaction (transactions are only created by the /authn api), so we should make the call directly:

var http = require('./http');

// ...

return http.get(this, url);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Got it!

lib/http.js Outdated
@@ -5,6 +5,7 @@ var storageUtil = require('./storageUtil');
var Q = require('q');
var AuthApiError = require('./errors/AuthApiError');
var config = require('./config');
var $ = require('jquery');
Copy link
Contributor

@lboyette-okta lboyette-okta Oct 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to keep auth-js small and jQuery is a pretty big dependency, so if a dev wants to use jquery, they have to do it explicitly.

For example, normally, okta-auth-js is imported like this: var oktaAuth = require('@okta/okta-auth-js'). This uses a small library called reqwest to make http requests. If a dev wants to use jQuery to makes requests instead, they can import okta-auth-js like this: var oktaAuth = require('@okta/okta-auth-js/jquery').

So, yeah, it's a good idea to avoid it when possible

lib/http.js Outdated
@@ -28,7 +29,7 @@ function httpRequest(sdk, options) {
'Content-Type': 'application/json',
'X-Okta-User-Agent-Extended': 'okta-auth-js-' + config.SDK_VERSION
};
util.extend(headers, sdk.options.headers || {});
$.extend(headers, sdk.options.headers, options.headers);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make util.extend behave more like jQuery instead of importing jQuery.

Alternatively, you could call util.extend twice, but it'd be much cleaner if it accepted an arbitrary number of arguments.

lib/tx.js Outdated
@@ -55,6 +55,10 @@ function postToTransaction(sdk, url, options) {
});
}

function getFromTransaction(sdk, url, options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

define(function(require) {
var util = require('../util/util');

describe('WEBFINGER', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lowercase is ok here. The others are capitalized because they're states in the /authn api

@gowthamidommety-okta gowthamidommety-okta force-pushed the gd-OKTA-145614-webfingerSupport branch from 421d2b0 to 3a9cbf7 Compare November 1, 2017 04:41
Copy link
Contributor

@lboyette-okta lboyette-okta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Adds support for Webfinger API calls

Resolves: OKTA-145614
@gowthamidommety-okta gowthamidommety-okta force-pushed the gd-OKTA-145614-webfingerSupport branch from 3a9cbf7 to 2a4a535 Compare November 1, 2017 18:29
@gowthamidommety-okta gowthamidommety-okta merged commit 4982c06 into master Nov 1, 2017
@jmelberg-okta jmelberg-okta deleted the gd-OKTA-145614-webfingerSupport branch June 15, 2018 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants