Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit c950a46

Browse files
authored
Merge pull request #1319 from stormpath/okta-spring-boot-demo
Bunches of changes for the okta branch
2 parents 619c367 + d38aa82 commit c950a46

File tree

176 files changed

+3071
-1355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+3071
-1355
lines changed

OktaGettingStarted.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
2+
Getting Started With Okta
3+
=========================
4+
5+
Okay, so you have been using Stormpath for a while and now you want to checkout out Okta. This guide will walk through
6+
setting up a new account, creating an API token, and everything else needed to get you up and running on Okta.
7+
8+
Create an Okta Developer Account
9+
--------------------------------
10+
11+
1. Head on over to: https://www.okta.com/developer/signup/
12+
2. Fill out the signup form, and click the "Get Started" button
13+
3. Within a few minutes you will get a conformation email
14+
4. Follow the instructions in the email to finish setting up your account
15+
16+
17+
Your Okta URLs
18+
--------------
19+
20+
When setting up a developer account, you end up with a couple URL:
21+
An admin console URL that looks something like this:
22+
23+
https://dev-123456-admin.oktapreview.com/admin/getting-started
24+
25+
Use this one to manually change organization settings, create users, or other general administrative work. The other URL looks similar, but is missing the `admin` part:
26+
27+
https://dev-123456.oktapreview.com/
28+
29+
This is the one your yours could interact with, and will be the base URL for any API access.
30+
31+
**Important:** The second URL (the non-admin one) is the one you will need to remember, you will use this one for API access.
32+
33+
Setup your Okta 'Organization'
34+
------------------------------
35+
36+
### Create an Application
37+
38+
1. Navigate to your Admin console: i.e. https://dev-123456-admin.oktapreview.com/admin/dashboard
39+
2. On the top menu click on 'Applications'
40+
3. Press the 'Add Application' button
41+
4. Press the 'Create New App' button
42+
5. On the 'Create a New Application Integration' popup fill select the following values, then press the 'Create' button
43+
- Platform - Native
44+
- Sign-on Method - OpenID Connect
45+
6. On the 'Create OpenID Connect Integration' page enter the following values, and press the 'Next' button
46+
- Application Name - 'My Test Application'
47+
7. Use `http://localhost:8080/client/callback` for the Redirect URI's, and press the 'Finish' button
48+
8. Your application has been created, but you still have a few settings to change. On the 'General' tab, click the 'Edit' button on the 'General Settings' panel
49+
9. Select the 'Refresh Token', and 'Resource Owner Password' checkboxes and click the 'Save' button
50+
10. Click the 'Edit' button on the 'Client Credentials' panel
51+
11. Select the 'Use Client Authentication' radio button, and press the 'Save' button
52+
12. Click on the 'Groups' tab
53+
13. Select the 'Assign' button in the 'Everyone' column, and press the 'Done' button
54+
14. Grab the ID portion of the URL of your browsers current page, for example: if my URL was: `https://dev-123456-admin.oktapreview.com/admin/app/oidc_client/instance/00icu81200icu812/#tab-groups` then `00icu81200icu812` would be your application's ID
55+
56+
**Important:** You will need to remember your application's ID.
57+
58+
### Create an Access Token
59+
60+
1. Navigate to your Admin console: i.e. https://dev-123456-admin.oktapreview.com/admin/dashboard
61+
2. On the top menu click on 'Security' -> 'API'
62+
3. Select the 'Tokens' tab
63+
4. Press the 'Create Token' button
64+
5. On the popup, give your new token a name, for example: 'My Test Token', and press the 'Create Token' button
65+
66+
**Important:** You will need to remember this token value, so copy/paste it somewhere safe.
67+
68+
For more information take a look at the official [Create an API token](http://developer.okta.com/docs/api/getting_started/getting_a_token.html) guide.
69+
70+
71+
Run an Example Application
72+
--------------------------
73+
74+
Since you are reading this page on Github, I'm going to assume you know how to clone this repo, and switch to the `okta` branch, once you have done that, build the current SNAPSHOT with Apache Maven.
75+
76+
``` bash
77+
$ mvn clean install
78+
```
79+
80+
This should not take more then a couple minutes.
81+
82+
Once complete change directories to examples/spring-boot-default
83+
84+
``` bash
85+
$ cd examples/spring-boot-default
86+
```
87+
88+
The last step before running our example is to set your configuration variables, there are a [few different ways](https://docs.stormpath.com/java/servlet-plugin/config.html) you can do this, but I'll just use environment variables here.
89+
90+
``` bash
91+
$ export STORMPATH_CLIENT_BASEURL=[baseurl_from_above]
92+
$ export OKTA_APPLICATION_ID=[aapplication_id_from_above]
93+
$ export OKTA_API_TOKEN=[api_token_from_above]
94+
```
95+
96+
Start it up!
97+
98+
``` bash
99+
$ mvn spring-boot:run
100+
```
101+
102+
Point your browser to: http://localhost:8080 and start using the example application!
103+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ We are incredibly excited to announce that [Stormpath is joining forces with Okt
66

77
We're available to answer all questions at [[email protected]](mailto:[email protected]).
88

9+
## Okta Support Branch
10+
11+
The aim of this branch is to port the Stormpath Java integrations (Spring, Spring-Boot, and Servlet) to work with Okta's API instead of Stormpath.
12+
13+
Take a look at the [Getting Started With Okta](OktaGettingStarted.md) guide for instructions on how to get started.
14+
15+
**Work on this branch is on going**, but if you want to try it out you can build it with Apache Maven: `mvn install`
16+
17+
You will also need to set the following properties (these can be set the same way as your [existing Stormpath configuration properties](https://docs.stormpath.com/java/servlet-plugin/config.html#id10)).
18+
19+
| Key | Description |
20+
|-----|-------------|
21+
| okta.api.token | [An Okta API key](http://developer.okta.com/docs/api/getting_started/getting_a_token.html) |
22+
| okta.application.id | You find your Application's id with an [API call](http://developer.okta.com/docs/api/resources/apps.html), or by opening your 'application' config in the Okta Admin console and grab the ID from your browsers URL |
23+
| stormpath.client.baseUrl | The base url of your Okta organization, for example in a preview enviornment this would be something like: https://dev-123456.oktapreview.com |
24+
925
# Stormpath Java SDK #
1026

1127
*An advanced, reliable and easy-to-use user management API, built by Java security experts*

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<parent>
2222
<groupId>com.stormpath.sdk</groupId>
2323
<artifactId>stormpath-sdk-root</artifactId>
24-
<version>1.6.0-SNAPSHOT</version>
24+
<version>2.0.0-okta-alpha-SNAPSHOT</version>
2525
<relativePath>../pom.xml</relativePath>
2626
</parent>
2727

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.stormpath.sdk.application;
2+
3+
import com.stormpath.sdk.oauth.IdSiteAuthenticator;
4+
import com.stormpath.sdk.oauth.OAuthBearerRequestAuthenticator;
5+
import com.stormpath.sdk.oauth.OAuthClientCredentialsGrantRequestAuthenticator;
6+
import com.stormpath.sdk.oauth.OAuthPasswordGrantRequestAuthenticator;
7+
import com.stormpath.sdk.oauth.OAuthRefreshTokenRequestAuthenticator;
8+
import com.stormpath.sdk.oauth.OAuthStormpathFactorChallengeGrantRequestAuthenticator;
9+
import com.stormpath.sdk.oauth.OAuthStormpathSocialGrantRequestAuthenticator;
10+
import com.stormpath.sdk.oauth.OAuthTokenRevocator;
11+
12+
/**
13+
* Marks an Application as supporting OAuth and adds required methods for handling tokens.
14+
*/
15+
public interface OAuthApplication extends Application {
16+
17+
OAuthClientCredentialsGrantRequestAuthenticator createClientCredentialsGrantAuthenticator();
18+
19+
OAuthStormpathSocialGrantRequestAuthenticator createStormpathSocialGrantAuthenticator();
20+
21+
OAuthStormpathFactorChallengeGrantRequestAuthenticator createStormpathFactorChallengeGrantAuthenticator();
22+
23+
OAuthPasswordGrantRequestAuthenticator createPasswordGrantAuthenticator();
24+
25+
OAuthRefreshTokenRequestAuthenticator createRefreshGrantAuthenticator();
26+
27+
OAuthBearerRequestAuthenticator createJwtAuthenticator();
28+
29+
OAuthTokenRevocator createOAuhtTokenRevocator();
30+
31+
// FIXME: this shouldn't be here, but not sure how much of the IdSite code is just OAuth functionality.
32+
IdSiteAuthenticator createIdSiteAuthenticator();
33+
34+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
import java.util.Map;
6+
7+
/**
8+
* Representation of /api/v1/authn
9+
*/
10+
public interface AuthNRequest extends Resource {
11+
12+
String getUsername();
13+
AuthNRequest setUsername(String username);
14+
15+
String getPassword();
16+
AuthNRequest setPassword(String password);
17+
18+
Map<String, Object> getOptions();
19+
AuthNRequest setOptions(Map<String, Object> options);
20+
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
import java.util.Map;
6+
7+
/**
8+
* Representation of /api/v1/authn
9+
*/
10+
public interface AuthNResult extends Resource {
11+
12+
String getSessionToken();
13+
14+
String getUserId();
15+
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface OIDCKey extends Resource {
9+
10+
String getAlgorithm();
11+
String getId();
12+
String getType();
13+
String getUse();
14+
15+
String get(String id);
16+
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
import java.security.Key;
6+
import java.util.Set;
7+
8+
/**
9+
*
10+
*/
11+
public interface OIDCKeysList extends Resource {
12+
13+
Set<OIDCKey> getKeys();
14+
OIDCKey getKeyById(String keyId);
15+
16+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface OktaForgotPasswordRequest extends Resource {
9+
10+
String getUsername();
11+
OktaForgotPasswordRequest setUsername(String username);
12+
13+
String getFactorType();
14+
OktaForgotPasswordRequest setFactorType(String factorType);
15+
16+
String getRelayState();
17+
OktaForgotPasswordRequest setRelayState(String relayState);
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface OktaForgotPasswordResult extends Resource {
9+
10+
String getStatus();
11+
String getFactorResult();
12+
String getRelayState();
13+
String getFactorType();
14+
String getRecoveryType();
15+
16+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface OktaTokenRequest extends Resource {
9+
10+
String getGrantType();
11+
OktaTokenRequest setGrantType(String grantType);
12+
13+
String getRedirectUri();
14+
OktaTokenRequest setRedirectUri(String redirectUri);
15+
16+
String getUsername();
17+
OktaTokenRequest setUsername(String username);
18+
19+
String getPassword();
20+
OktaTokenRequest setPassword(String password);
21+
22+
String getScope();
23+
OktaTokenRequest setScope(String scope);
24+
25+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.oauth.TokenResponse;
4+
import com.stormpath.sdk.resource.Resource;
5+
6+
/**
7+
*
8+
*/
9+
public interface OktaTokenResponse extends Resource, TokenResponse {
10+
11+
String getAccessToken();
12+
13+
String getTokenType();
14+
15+
String getExpiresIn();
16+
17+
String getScope();
18+
19+
String getRefreshToken();
20+
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface TokenIntrospectRequest extends Resource {
9+
10+
String getToken();
11+
TokenIntrospectRequest setToken(String token);
12+
13+
String getTokenTypeHint();
14+
TokenIntrospectRequest setTokenTypeHint(String tokenTypeHint);
15+
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.stormpath.sdk.application.okta;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
import java.util.Date;
6+
7+
/**
8+
*
9+
*/
10+
public interface TokenIntrospectResponse extends Resource {
11+
12+
boolean isActive();
13+
String getScope();
14+
String getUsername();
15+
Date getExpiresAt();
16+
Date getIssuedAt();
17+
String getSubject();
18+
String getAudience();
19+
String getIssuer();
20+
String getJwtId();
21+
String getTokenType();
22+
String getClientId();
23+
String getUid();
24+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.stormpath.sdk.authc;
2+
3+
import com.stormpath.sdk.resource.Resource;
4+
5+
/**
6+
*
7+
*/
8+
public interface OktaAuthNAuthenticator extends Resource {
9+
10+
AuthenticationResult authenticate(AuthenticationRequest request);
11+
12+
void assertValidAccessToken(String accessToken);
13+
}

api/src/main/java/com/stormpath/sdk/client/ClientBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public interface ClientBuilder {
222222
String DEFAULT_CLIENT_PROXY_HOST_PROPERTY_NAME = "stormpath.client.proxy.host";
223223
String DEFAULT_CLIENT_PROXY_USERNAME_PROPERTY_NAME = "stormpath.client.proxy.username";
224224
String DEFAULT_CLIENT_PROXY_PASSWORD_PROPERTY_NAME = "stormpath.client.proxy.password";
225+
String DEFAULT_OKTA_ENABLED_PROPERTY_NAME = "okta.enabled";
225226

226227
/**
227228
* Allows specifying an {@code ApiKey} instance directly instead of relying on the

0 commit comments

Comments
 (0)