Okta Custom Attribute per each application - okta

I have a question, can i have the same Custom Attribute for User Profile, but different value per each application that User have
Example:
App1
Name:John Test
ApplicationRole: Admin
App2
Name: John Test
ApplicationRole: Cashier
or i need to create one Custom Attribute for each App?
Thanks.

Value for custom attribute created in Okta profile will be global for each user in Okta. So you cannot do it that way.
What you need is custom attribute per app. However, admin would need to set those two custom attribute values for same user per app. Or you could use API call to do it. Lets say your custom attribute for each app is called ApplicationRole. Assuming same user is assigned to both app. In that case.
For App1
/api/v1/apps//users/
{
"profile": {
"ApplicationRole": "Admin"
}
}
For App2
/api/v1/apps//users/
{
"profile": {
"ApplicationRole": "Cashier"
}
}

Related

Different registration page for different users

I used laravel framework to create a job portal and the web app will be used by the job seeker and the employer. How do i create a different registration page for those users?
You can define different routes and views as per the user type.
For instance:
Job seeker registration route:
Route::get('job-seeker/registration', function(){
return view('job-seeker.registration');
});
Employer registration:
Route::get('employer/registration', function(){
return view('employer.registration');
});
And then you can customize views as per your requirement.
You can use auth()->user->attribute in order to return a different view if you want to discrimine the type of user by an attribute in the users table.
Try like this in route page.
Route::get('/register/job','RegisterController#jobseeker');
Route::get('/register/employer','RegisterController#employer');

Laravel 5.1 use session to restrict direct access using urls users based on user role

I have 2 laravel projects, 1 for the front end where i m using html css angularjs. The second for api controllers. I call using http post and get the api controllers functions using angularjs to get content data.
In the front end i have a menu this menu appears differently based on user role, if admin or no.
This is done. My problem is the access for views using the url in the browser.
So I have a query where I get for each user what modules in the menu can he see. Now I'm putting the result in Laravel session.
$menu = DB::select menu by user id ... //Getting menu query based on user if admin or no
session(["menu" => $menu);
return session('menu');
I'm getting the results and the menu is showing good in the website based on the logged user if he s admin or no.
Now, to solve the direct url access issue, I want to use this session and compare the url to this session, if the url exists in the session i will let him access, if no i will redirect him to somewhere.
any idea?
I would strongly suggest looking at the Laravel documentation on Authorization before going too far down a custom implementation:
https://laravel.com/docs/5.1/authorization
Without knowing more about how your front-end and back-end applications interact with each other, it is a little difficult to get into speciifics but i shall do my best.
Each page returned by Laravel has access to a Request object which contains information about the request which returned the page. You can access this Request and its assocaited Route using Laravels helper functions (if you are not passing it to the view already). The getPrefix() method will return the root relative url which you can then use as you see fit. For example:
// Return and store the URL as a string
$url = request()->route()->getPrefix();
// Check your session for the URL/s you want to allow and compare to the stored URL
if (session()->get('URL') == $url) {
// User is allowed access to the page
// Do something ...
} else {
// User is not allowed access to this page
// Redirect back or to a route of your choice
return redirect()->back();
}
I hope this gives you some ideas, good luck!

Is it possible to get Laravel user data from Vue JS?

i have a Laravel 5.4 application where i do all Authentication based logic through PHP and then redirect the user to a catchAll route when they are authenticated, and let VueRouter take it from there...
I'd like to also use Entrust because my app will have several types of users and some elements (like an Edit User button) will only be visible to some user Roles.
I might also want to implement specific permissions, like some Admins can edit user Permissions, while others do not.
The issue is, alright i'm in Javascript territory now, so how do i know what my current Auth user is? Setting a global JS variable for Auth::user doesn't seem like a good idea to me.
Perhaps i would instead pass just an ID, but how exactly without making it globally visible as a window variable?
I think you may create an auth/check API call, like this:
protected function check()
{
if(Auth::guard('api')->check()) {
return Auth::guard('api')->user();
}
return ['success' => false];;
}
And then get current user with this call.

Change group of a newly created User in PyroCMS

Using PyroCMS 2.2, how can I have a registration form assign a user to one of the new Groups I created. Within the admin panel, I have a created a user group called client. When my registration form within my module is sent, it creates the client, but sets the type for group to $config['default_group'] = 'user'; within the core module.
Is there a way for me to set the group to client for this specific registration form in this module?
I suggest this:
When you redirect the user to the costum registration form, set a session variable with value of your costume module name for example
Use PyroCMS events (Events::trigger('post_user_register', $id)) and build a events.php file for your module so that, after every user registration this event will be triggered and since you have set the session variable, you can decide to change the user group of newly created user to an appropriate one and be sure to unset the session variable after you are done.
Hope you get the idea.
It doesn't look like there is an inbuilt way to do this.
system/cms/modules/users/controllers/users.php:384
// We are registering with a null group_id so we just
// use the default user ID in the settings.
$id = $this->ion_auth->register($username, $password, $email, null, $profile_data);
It also appears it isn't possible to override the core modules.
Seems like you have 2 options:
Modify the core module
Try to port the user module into your own module

Grails Request Map custom errors

I've got a websoftware done with Grails that uses request maps from Spring Security.
I am using them for security reasons, so that the user can't access admin areas but also it's used for our business model. We've got two different user roles. One is premium and one is premium plus, while PREMIUM_PLUS > PREMIUM.
The premium plus user can access some more pages than the premium user can. If a premium user wants to access a page that can only get called by a premium plus user, there will be a error like 'no access', but I want a custom message like 'Upgrade now to premium plus'.
I could easily edit the template for all request maps errors but there are also some restricted pages nobody should see where a message like 'no access' is perfect for.
Is there any possibility to do this with two different error pages?
Thank you.
The LoginController have the action denied that shows the denied.gsp. You can customize your controller action to check if you need to display the upgrade page or the denied page.
class LoginController {
def denied() {
if (springSecurityService.isLoggedIn() &&
authenticationTrustResolver.isRememberMe(SCH.context?.authentication)) {
// have cookie but the page is guarded with IS_AUTHENTICATED_FULLY
redirect action: 'full', params: params
} else {
//implement a method checking whatever you need to define that will display the upgrade
if(mustShowUpgrade()) {
render view: 'upgrade'
}
}
}
}

Resources