Comments (4)
The redirect
parameter in the ImperialMiddleware
initializer is the path to redirect the client to if they are not authenticated.
I have outlined how to actually authenticate the user in the Google auth guide.
Basically you register the auth route like this:
try router.oAuth(from: Google.self, authenticate: "google", callback: "http://localhost:8080/google-complete")
Then the client can go to the /google
route, which will redirect them to Google for sign-in.
from imperial.
Ok I see, thanks for your awnser.
But, I need to create the /google
route? Because by default, I have just the message in log and not redirection. My code is:
try router.oAuth(from: Google.self, authenticate: "google", callback: "http://localhost:8080/google-complete", scope: ["https://www.googleapis.com/auth/cloud-platform"]) { (request, token) in
print(token)
return request.future(request.redirect(to: "/"))
}
And
let protected = router.grouped(ImperialMiddleware())
protected.get("hello") { req in
return "Hello, world!"
}
And I get {"error":true,"reason":"User currently not authenticated"}
but no redirection.
If I need to create this route, how I can get the authURL
available in GoogleRouter.swift
with clientID, scope, etc?
Thanks you, for the project and your quick response!
from imperial.
The /google
route is automatically created by the router.oAuth
call. You should be good to go!
from imperial.
OK, thanks for the details!
I'll be back soon with a merger request for Keycloak support.
from imperial.
Related Issues (20)
- Unit tests crash with "Fatal error: Unexpectedly found nil while unwrapping an Optional value" HOT 1
- Callback URL registered incorrectly if using route groups
- Callback URL registered incorrectly if using route groups
- How to access JWT scopes? HOT 2
- How to use with Vapor 4? HOT 2
- Redirect Url not called HOT 2
- Docker build error - ambiguous use of 'hex' HOT 3
- Session access token encoding error for Facebook callback HOT 1
- Add logic for pulling and saving refresh tokens on sessions
- Vapor 4 update HOT 2
- can't find www.accounts.google.com HOT 1
- Value required for key 'access_token'. HOT 8
- Bug with coding strategy HOT 1
- Auth0 support missing HOT 2
- Completion Closure Not Invoked When Using Google Auth HOT 1
- Maybe it is possible to update Imperial to async/await? HOT 3
- Missing code key in url query HOT 19
- Solved
- Is it a way not make Github call directly backend, but let Github call frontend first, and frontend call gh-auth-complete in backend and pass code? HOT 2
- id like to rename callback to redirectURL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imperial.